Beispiel #1
0
def test_to_json_traits(tracking_plan_yaml, tracking_plan_trait_yaml):
    plan = YamlTrackingPlan(tracking_plan_yaml)
    plan.add_identify_trait(tracking_plan_trait_yaml)

    json_plan = plan.to_json()

    json_traits = json_plan['rules']['identify']['properties']['traits'][
        'properties']

    assert len(json_traits) == 1
    expected = YamlProperty(tracking_plan_trait_yaml).to_json()
    actual = json_traits['email']
    assert actual == expected
Beispiel #2
0
 def add_group_trait(self, trait_yaml):
     trait_property = YamlProperty(trait_yaml)
     self._group_traits.append(trait_property)
Beispiel #3
0
 def add_identify_trait(self, trait_yaml):
     trait_property = YamlProperty(trait_yaml)
     self._identify_traits.append(trait_property)
Beispiel #4
0
def test_valid_name(property_yaml_obj):
    property_yaml_obj['name'] = 'FooBar'

    with assert_raises_validation_error(
            expected_msg="FooBar is not a valid property name"):
        YamlProperty(property_yaml_obj)
Beispiel #5
0
def test_valid_type(property_yaml_obj):
    property_yaml_obj['type'] = 'foo'
    property_yaml_obj.pop('pattern')
    with assert_raises_validation_error(
            expected_msg="Type foo is not a valid property type"):
        YamlProperty(property_yaml_obj)
Beispiel #6
0
def test_validate_pattern_on_string_type(property_yaml_obj):
    property_yaml_obj['type'] = 'number'

    with assert_raises_validation_error(
            expected_msg=f'Property variation cannot specify a pattern'):
        YamlProperty(property_yaml_obj)
Beispiel #7
0
 def __init__(self, event_yaml):
     self._event_yaml = event_yaml
     self._properties = [YamlProperty(p) for p in event_yaml['properties']]
     self.validate()