def test_invalid_toml(self):
     filename = make_test_file_path('invalid_toml')
     with self.assertRaises(ExceptionGroup) as context:
         process_files([filename])
     error_group = context.exception
     assert len(error_group.errors) == 1
     assert type(error_group.errors[0]) == pytoml.TomlError
 def test_missing_file(self):
     filename = make_test_file_path('file_does_not_exist')
     with self.assertRaises(ExceptionGroup) as context:
         process_files([filename])
     error_group = context.exception
     assert len(error_group.errors) == 1
     assert type(error_group.errors[0]) == FeatureGateException
     assert 'No such file or directory' in str(error_group.errors[0])
 def test_empty_feature(self):
     filename = make_test_file_path('empty_feature')
     with self.assertRaises(ExceptionGroup) as context:
         process_files([filename])
     error_group = context.exception
     assert len(error_group.errors) == 1
     assert type(error_group.errors[0]) == FeatureGateException
     assert 'required key not provided' in str(error_group.errors[0])
Example #4
0
 def test_valid_file(self):
     filename = make_test_file_path("good")
     result = process_files([filename])
     assert result == {
         "demo-feature": {
             "id": "demo-feature",
             "title": "Demo Feature",
             "description": "A no-op feature to demo the feature gate system.",
             "restartRequired": False,
             "preference": "foo.bar.baz",
             "type": "boolean",
             "bugNumbers": [1479127],
             "isPublic": {"default": True},
             "defaultValue": {"default": False},
         },
         "minimal-feature": {
             "id": "minimal-feature",
             "title": "Minimal Feature",
             "description": "The smallest feature that is valid",
             "restartRequired": True,
             "preference": "features.minimal-feature.enabled",
             "type": "boolean",
             "bugNumbers": [1479127],
             "isPublic": {"default": False},
             "defaultValue": {"default": None},
         },
     }