コード例 #1
0
ファイル: configurations.py プロジェクト: ukaea/piezo
    def _parse(self, path):
        config = configparser.ConfigParser()
        config.read(path)
        logging = config["Logging"]
        application = config["Application"]
        storage = config["Storage"]

        # Logging
        self._log_folder_location = self.get_directory(logging,
                                                       "LogFolderLocation")
        self._logging_level = logging["LoggingLevel"]

        # Application
        self._app_port = str2non_negative_int(application['ApplicationPort'])
        self._k8s_url = application['K8sUrl']
        self._k8s_cluster_config_file = application['K8sClusterConfigFile']
        self._tidy_frequency = str2non_negative_int(
            application['TidyFrequency'])

        # Storage
        self._s3_endpoint = storage['S3Endpoint']
        self._s3_bucket_name = storage['S3BucketName']
        self._s3_secrets_name = storage['S3KeysSecret']
        self._secrets_dir = storage['SecretsDir']
        self._temp_url_expiry_seconds = str2non_negative_int(
            storage['TempUrlExpirySeconds'])
コード例 #2
0
def test_str2non_negative_int_accepts_positive_integer():
    string = "42"
    integer = str2non_negative_int(string)
    assert integer == 42
コード例 #3
0
def test_str2non_negative_int_throws_type_error_for_none():
    with pytest.raises(TypeError):
        str2non_negative_int(None)
コード例 #4
0
def test_str2non_negative_int_throws_value_error_for_empty_string():
    with pytest.raises(ValueError):
        str2non_negative_int("")
コード例 #5
0
def test_str2non_negative_int_throws_value_error_for_negative_float():
    with pytest.raises(ValueError):
        str2non_negative_int("-42.5")
コード例 #6
0
def test_str2non_negative_int_throws_value_error_for_negative_integer():
    with pytest.raises(ValueError) as exception_info:
        str2non_negative_int("-42")
    assert str(exception_info.value) == "'-42' is not a non-negative integer"
コード例 #7
0
def test_str2non_negative_int_accepts_zero():
    string = "0"
    integer = str2non_negative_int(string)
    assert integer == 0