def test_create_existing_json_file(self): f = tempfile.NamedTemporaryFile(mode='w+', suffix='.json', delete=False) f.write('{"test": {"queue": {"type": "mock"}, "storage": {"type": "mock"}, "log_level": "DEBUG"}}') f.close() try: os.environ['DINO_ENVIRONMENT'] = 'test' create_env([f.name]) finally: os.remove(f.name)
def test_create_existing_yaml_file(self): f = tempfile.NamedTemporaryFile(mode='w+', suffix='.yaml', delete=False) f.write('test:\n log_level:\n "DEBUG"\n storage:\n ' ' type: "mock"\n queue:\n type: "mock"') f.close() try: os.environ['DINO_ENVIRONMENT'] = 'test' create_env([f.name]) finally: os.remove(f.name)
def test_log_level_has_default_value(self): f = tempfile.NamedTemporaryFile(mode='w+', suffix='.yaml', delete=False) f.write('test:\n storage:\n type: "mock"\n queue:\n type: "mock"') f.close() try: os.environ['DINO_ENVIRONMENT'] = 'test' env = create_env([f.name]) self.assertIsNotNone(env.config.get(ConfigKeys.LOG_LEVEL)) finally: os.remove(f.name)
def test_init_acl_validators(self): os.environ['DINO_ENVIRONMENT'] = 'integration' env = create_env() env.db = FakeDb() environ.init_acl_validators(env)
def test_init_database(self): os.environ['DINO_ENVIRONMENT'] = 'integration' env = create_env() env.db = FakeDb() environ.init_database(env)
def test_create_with_environment(self): os.environ['DINO_ENVIRONMENT'] = 'integration' env = create_env() self.assertTrue(ConfigKeys.LOG_FORMAT in env.config.keys()) self.assertTrue(ConfigKeys.LOG_LEVEL in env.config.keys()) self.assertTrue(ConfigKeys.SESSION in env.config.keys())
def test_env(self): if 'DINO_ENVIRONMENT' in os.environ: del os.environ['DINO_ENVIRONMENT'] env = create_env() self.assertEqual(0, len(env.config))