Example #1
0
    def test_used_config(self):
        config = self.config.read(
            config_reader=ConfigMock('ProductionConfig').config_reader)
        self.assertEqual('Production', config.DebugId)

        config = self.config.read(
            config_reader=ConfigMock('DevelopmentConfig').config_reader)
        self.assertEqual('Development', config.DebugId)

        config = self.config.read(
            config_reader=ConfigMock('TestingConfig').config_reader)
        self.assertEqual('Testing', config.DebugId)
Example #2
0
 def test_multi_level_inheritance(self):
     config = self.config.read(
         config_reader=ConfigMock('DependencyTopConfig').config_reader)
     self.assertEqual('DependencyTop', config.DebugId)
     self.assertDictEqual({
         1: 'Top',
         2: 'Middle',
         3: 'Bottom',
     }, config.DependencyLevel.get_dict())
Example #3
0
    def test_str_dump_validity(self):
        config = self.config.read(
            config_reader=ConfigMock('DevelopmentConfig').config_reader)
        assert """{'App': {'MIGRATE_REPO_PATH': '/test/db_repository',
         'UTF8_VALUE': 'Több hűtőházból kértünk színhúst'},
 'DebugId': 'Development',
 'Flask': {'DEBUG': True,
           'SERVER_NAME': '0.0.0.0:8000',
           'STATIC_FOLDER': '/test',
           'TESTING': False},
 'SqlAlchemy': {'SQLALCHEMY_DATABASE_URI': 'sqlite:///test/app.sqlite'}}""" == str(
            config)
Example #4
0
 def test_substitution(self):
     config = self.config.read(
         config_reader=ConfigMock('DevelopmentConfig').config_reader)
     self.assertNotIn('$BASE', config.App.MIGRATE_REPO_PATH)
     self.assertEqual('/test/db_repository', config.App.MIGRATE_REPO_PATH)
Example #5
0
 def test_magic_attribute_not_exits_exception(self):
     try:
         self.config.read(config_reader=ConfigMock(
             'ProductionConfig').config_reader).not_exited_attribute
     except Exception as e:
         self.assertIsInstance(e, AttributeError)
Example #6
0
 def test_multi_level_circular_dependency_in__inheritance(self):
     try:
         self.config.read(config_reader=ConfigMock(
             'MultiCircularConfigTop').config_reader)
     except Exception as e:
         self.assertIsInstance(e, CircularDependencyError)
Example #7
0
 def test_single_level_circular_dependency_in_inheritance(self):
     try:
         self.config.read(config_reader=ConfigMock(
             'MinimalCircularConfig').config_reader)
     except Exception as e:
         self.assertIsInstance(e, CircularDependencyError)
Example #8
0
 def test_single_level_inheritance(self):
     config = self.config.read(
         config_reader=ConfigMock('DevelopmentConfig').config_reader)
     self.assertIn('MIGRATE_REPO_PATH', config.App)
     self.assertIn('SqlAlchemy', config)
Example #9
0
 def test_config_key_getter(self):
     config = self.config.read(
         config_reader=ConfigMock('DefaultConfig').config_reader)
     self.assertIn('MIGRATE_REPO_PATH', config['App'])
Example #10
0
 def test_config_iterator(self):
     config = self.config.read(
         config_reader=ConfigMock('DefaultConfig').config_reader)
     self.assertIn('App', config)
     self.assertIn('MIGRATE_REPO_PATH', config.App)
Example #11
0
 def test_can_not_set_not_existed_value_by_attr(self):
     config = self.config.read(
         config_reader=ConfigMock('DefaultConfig').config_reader)
     config.Flask.NEW_PROPERTY = '/new_path'
     assert 'NEW_PROPERTY' not in config.Flask
Example #12
0
 def test_can_set_not_existed_value_by_key(self):
     config = self.config.read(
         config_reader=ConfigMock('DefaultConfig').config_reader)
     config.Flask['NEW_PROPERTY'] = '/new_path'
     assert 'NEW_PROPERTY' in config.Flask
     assert config.Flask.NEW_PROPERTY == '/new_path'
Example #13
0
 def test_can_not_set_existed_value_by_attr(self):
     config = self.config.read(
         config_reader=ConfigMock('DefaultConfig').config_reader)
     config.Flask.STATIC_FOLDER = '/new_path'
     assert config.Flask.STATIC_FOLDER == '/test'