f9a6c8418f
The schema is written in Python to reduce duplication. When configuration is loaded, the validation checks if it's correct and fills in default values. There is a custom extension to the schema to report deprecated options. The config dependencies are implemented as a separate pass. While it's technically possible to express the dependencies in the schema itself, the error messages are not very helpful and it makes the schema much harder to read. Phases no longer define `config_options`. New options should be added to the schema. Since the default values are populated automatically during validation, there is no need to duplicate them into the code. The `pungi-config-validate` script is updated to use the schema and report errors even for deeply nested fields. The dependencies are updated: pungi now depends on `python-jsonschema` (which is already available in Fedora). Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
#!/usr/bin/env python2
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import mock
|
|
import unittest
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
|
|
from pungi import paths
|
|
|
|
|
|
class TranslatePathTestCase(unittest.TestCase):
|
|
def test_does_nothing_without_config(self):
|
|
compose = mock.Mock(conf={'translate_paths': []})
|
|
ret = paths.translate_path(compose, '/mnt/koji/compose/rawhide/XYZ')
|
|
self.assertEqual(ret, '/mnt/koji/compose/rawhide/XYZ')
|
|
|
|
def test_translates_prefix(self):
|
|
compose = mock.Mock(conf={
|
|
'translate_paths': [('/mnt/koji', 'http://example.com')]
|
|
})
|
|
ret = paths.translate_path(compose, '/mnt/koji/compose/rawhide/XYZ')
|
|
self.assertEqual(ret, 'http://example.com/compose/rawhide/XYZ')
|
|
|
|
def test_does_not_translate_not_matching(self):
|
|
compose = mock.Mock(conf={
|
|
'translate_paths': [('/mnt/koji', 'http://example.com')]
|
|
})
|
|
ret = paths.translate_path(compose, '/mnt/fedora_koji/compose/rawhide/XYZ')
|
|
self.assertEqual(ret, '/mnt/fedora_koji/compose/rawhide/XYZ')
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|