Exemplo n.º 1
0
 def setUp(self):
     self.ordbok = Ordbok()
     self.config_file = ConfigFile('config.yml')
     self.config_file.init_config(self.ordbok)
Exemplo n.º 2
0
 def setUp(self):
     self.ordbok = Ordbok()
     self.config_file = ConfigFile('config.yml')
     self.config_file.init_config(self.ordbok)
Exemplo n.º 3
0
class OrdbokConfigFileTestCase(unittest.TestCase):
    def setUp(self):
        self.ordbok = Ordbok()
        self.config_file = ConfigFile('config.yml')
        self.config_file.init_config(self.ordbok)

    def test_file_add_required_keys(self):
        self.config_file.add_required_key('foo')
        self.config_file.add_required_key('bar', 'baz')
        self.assertIn('foo', self.config_file.required_keys)
        self.assertIn('bar', self.config_file.required_keys)
        self.assertNotIn('baz', self.config_file.required_keys)

    def test_file_validate_yaml_content(self):
        with self.assertRaises(TypeError):
            self.config_file._validate_yaml_content(['foo', 'bar', 'baz'])
        self.config_file._validate_yaml_content(
            {'foos': ['foo', 'bar', 'baz']})

    def test_file_validate_key(self):
        with self.assertRaises(OrdbokLowercaseKeyException):
            self.config_file._validate_key('foo')
        self.config_file._validate_key('FOO')

    def test_create_config_file(self):
        with self.assertRaises(TypeError):
            create_config_file(1)
        with self.assertRaises(TypeError):
            create_config_file({'foo': 'bar'})
        with self.assertRaises(TypeError):
            create_config_file(['foo', 'bar'])
Exemplo n.º 4
0
class OrdbokConfigFileTestCase(unittest.TestCase):
    def setUp(self):
        self.ordbok = Ordbok()
        self.config_file = ConfigFile('config.yml')
        self.config_file.init_config(self.ordbok)

    def test_file_add_required_keys(self):
        self.config_file.add_required_key('foo')
        self.config_file.add_required_key('bar', 'baz')
        self.assertIn('foo', self.config_file.required_keys)
        self.assertIn('bar', self.config_file.required_keys)
        self.assertNotIn('baz', self.config_file.required_keys)

    def test_file_validate_yaml_content(self):
        with self.assertRaises(TypeError):
            self.config_file._validate_yaml_content(['foo', 'bar', 'baz'])
        self.config_file._validate_yaml_content({'foos': ['foo', 'bar', 'baz']})

    def test_file_validate_key(self):
        with self.assertRaises(OrdbokLowercaseKeyException):
            self.config_file._validate_key('foo')
        self.config_file._validate_key('FOO')

    def test_create_config_file(self):
        with self.assertRaises(TypeError):
            create_config_file(1)
        with self.assertRaises(TypeError):
            create_config_file({'foo': 'bar'})
        with self.assertRaises(TypeError):
            create_config_file(['foo', 'bar'])