Esempio n. 1
0
    def test_settings_should_be_dict_like(self):
        settings = read_yaml(file_path=os.getenv('SETTINGS_PATH'))
        assert 'default' in settings
        assert hasattr(settings, 'get')

        expected = {
            'pipename': 'periodic-nightly',
            'users_file': 'config/test/users_test.yml',
            'secret_key': 'thisisverysecret'
        }
        # check only subset of config file to avoid bloating test source code
        assert settings['default'] == expected
Esempio n. 2
0
 def test_reader_raises_when_file_path_is_unexpected_type(self):
     with pytest.raises(TypeError):
         read_yaml(file_path=124234)
Esempio n. 3
0
 def test_settings_can_be_loaded_from_file_path_expect_types(self):
     read_yaml(file_path=os.getenv('SETTINGS_PATH'))
     read_yaml(file_path=os.path.normpath(os.getenv('SETTINGS_PATH')))
     read_yaml(
         file_path=bytes(os.getenv('SETTINGS_PATH'), encoding="utf-8"))
Esempio n. 4
0
 def test_reader_raises_when_file_path_does_not_exist(self):
     with pytest.raises(FileNotFoundError):
         read_yaml(file_path='/fake/path/settings.yml')
Esempio n. 5
0
 def test_settings_can_be_loaded(self):
     read_yaml(file_path=os.getenv('SETTINGS_PATH'))
Esempio n. 6
0
File: app.py Progetto: codilime/acid
from acid.controller import error_handlers
from acid.features.auth.controller import auth
from acid.features.auth.model import get_current_user
from acid.features.history.controller import builds
from acid.features.status.controller import status
from acid.features.status.service import get_zuul_pipelines
from acid.utils import pipe_intersect
from acid.features.zuul_manager.controller import zuul_manager
from acid.features.zuul_manager_v2.controller import zuul_manager_v2

if os.getenv('FLASK_ENV') == 'production' and not os.getenv('SECRET_KEY'):
    raise Exception("On production use environment variables")

app = Flask(__name__, static_folder='../static')

settings = read_yaml(file_path=os.path.normpath(os.getenv('SETTINGS_PATH')))
app.config.update(settings)

app.config['SECRET_KEY'] = os.getenv('SECRET_KEY',
                                     app.config['default']['secret_key'])
app.config['SESSION_TYPE'] = 'filesystem'
app.config['SESSION_PERMANENT'] = False

logging.config.fileConfig('config/logging.conf')
Session(app)

app.url_map.strict_slashes = False

app.register_blueprint(error_handlers)
app.register_blueprint(status)
app.register_blueprint(builds)
Esempio n. 7
0
 def is_admin(self):
     user_roles = read_yaml(current_app.config['default']['users_file'])
     return self.email in user_roles['admins']