
    ZTh                      N    d dl Z d dlmZ d dlmZmZ ddlmZmZm	Z	 d Z
d Zd Zy)	    N)SiftAPIDeprecationWarning)ChannelConfigChannelDataType   )$RuleActionCreateDataReviewAnnotationRuleActionCreatePhaseAnnotation
RuleConfigc                     d} t        dd| t               dt        dt        j                        dgdg	      }|j
                  | k(  sJ t        |j                        d
k(  sJ |j                  d   dk(  sJ d}t        j                  t        d      5  t        ddt        j                        }t        ddt        j                        }d d d        t        dd|t        ddgd      ddddgddi      }|j
                  dk(  sJ d}t        dd|t        ddgd      dt        dt        j                        dgdd i      }|j
                  d!k(  sJ y # 1 sw Y   xY w)"N$1 > 10zHigh VoltagezRock & Roll$1voltagename	data_typechannel_referencechannel_configtemperaturer   description
expressionactionchannel_referencescontextual_channelsr   r   z$1 == "Accelerating" && $2 > $3	component)matchvehicle_statemotor)r   r   r   overheatingz.checks if vehicle overheats while acceleratingfoobarzfoobar@baz.com)tagsassigneez$2z$3P   r   r   r   r   r   sub_expressionsz$1 == "Accelerating" && $2 > 80zcontains($1, $2)containslogErrorzcontains($1, "Error"))r	   r   r   r   DOUBLEr   lenr   pytestwarnsr   INT_32r   )voltage_rule_expressionvoltage_rule_configoverheating_rule_expressionchannel_with_component1channel_with_component2overheating_rule_configcontains_rule_expressioncontains_rule_configs           ^/home/www/backend.miabetepe.com/venv/lib/python3.12/site-packages/sift_py/rule/_config_test.pytest_rule_config_jsonr8      s   '$!*.0 &*"/"-44#
 +O  ))-DDDD"6671<<<2215FFF"C	/{	C 

"/ %,,#

 #0%,,#


 )D.3%
 &*"9
 &*"9	
 "
%, #--1RRRR1%D+3%
 &*"/-44#
 '
#*  **.EEEEu

 

s   9E!!E*c                      d} t        dd| t               dt        dt        j                        dgdd	d
      }|j
                  dk(  sJ y )Nz"0.5 * $mass * $1 * $1 > $thresholdrule_onkinetic_energyz$checks high periods of energy outputr   velocityr   r   
   #   )z$massz
$thresholdr%   z0.5 * 10 * $1 * $1 > 35)r	   r   r   r   r.   r   )kinetic_energy_gt_expressionrule_on_kinetic_energys     r7   test_rule_named_expressionsr@   b   si    #G '$:/.0 &*"/#-44#
 
& ",,0IIII    c                  J   t        dddt               dt        dt        j                        dgdd	g
      } t        | j                        dk(  sJ | j                  d   dk(  sJ | j                  d   d	k(  sJ | j                         }d|v sJ t        |d         dk(  sJ y)z9Test that RuleConfig properly handles contextual channels	test_rulez"test rule with contextual channelsr   r   r   r   r   humiditypressurer      r   r   contextual_channel_referencesN)r	   r   r   r   r*   r+   r   as_json)rule_configjson_outputs     r7   )test_rule_config_with_contextual_channelsrK   {   s    8.0 &*"/&-44#
 (4K" {../1444**1-;;;**1-;;; %%'K*k999{:;<AAArA   )r,   sift_py.errorr   sift_py.ingestion.channelr   r   configr   r   r	   r8   r@   rK    rA   r7   <module>rP      s,     3 D RFjJ2BrA   