Exemplo n.º 1
0
 def test_preference_experiments_unique_branch_values(self):
     action = ActionFactory(name="preference-experiment")
     arguments = {
         "slug":
         "test",
         "branches": [
             {
                 "slug": "a",
                 "value": "unique"
             },
             {
                 "slug": "b",
                 "value": "duplicate"
             },
             {
                 "slug": "c",
                 "value": "duplicate"
             },
         ],
     }
     with pytest.raises(serializers.ValidationError) as exc_info:
         action.validate_arguments(arguments, RecipeRevisionFactory())
     error = action.errors["duplicate_branch_value"]
     assert exc_info.value.detail == {
         "arguments": {
             "branches": {
                 2: {
                     "value": error
                 }
             }
         }
     }
Exemplo n.º 2
0
 def test_unique_branch_slugs(self):
     action = ActionFactory(name="multi-preference-experiment")
     arguments = MultiPreferenceExperimentArgumentsFactory(
         branches=[{"slug": "unique"}, {"slug": "duplicate"}, {"slug": "duplicate"}],
     )
     with pytest.raises(serializers.ValidationError) as exc_info:
         action.validate_arguments(arguments, RecipeRevisionFactory())
     error = action.errors["duplicate_branch_slug"]
     assert exc_info.value.detail == {"arguments": {"branches": {2: {"slug": error}}}}
Exemplo n.º 3
0
 def test_it_works(self):
     action = ActionFactory(name="nothing special")
     # does not raise an exception
     action.validate_arguments({}, RecipeRevisionFactory())
Exemplo n.º 4
0
 def create_revision(self, *args, **kwargs):
     return RecipeRevisionFactory(*args, **kwargs)