Ejemplo n.º 1
0
def test_read_config_missing_required_key_raises_error(s3git):
    with open(S3CONFIG_PATH, 'w') as w:
        w.write('[default]\n'
                'S3_ACCESS_KEY_ID = id\n'
                'S3_SECRET_ACCESS_KEY = secret\n')

    expected_error_cls = RequiredValueMissingInConfigurationFile
    expected_error_msg = expected_error_cls.MSG % ('default', 'S3_BUCKET_NAME')

    with pytest.raises(expected_error_cls, message=expected_error_msg):
        S3Bucket.read_config('none')
Ejemplo n.º 2
0
def test_read_config_missing_no_fit_section_found(s3git):
    """
    Happens when there is no default section
    or no section with the name of the current branch.
    """
    with open(S3CONFIG_PATH, 'w') as w:
        w.write('[branch]\n'
                'S3_ACCESS_KEY_ID = id\n'
                'S3_SECRET_ACCESS_KEY = secret\n'
                'S3_BUCKET_NAME = hi_bucket')

    expected_error_cls = MissingSectionConfigurationFile
    expected_error_msg = expected_error_cls.MSG % S3CONFIG_PATH

    with pytest.raises(expected_error_cls, message=expected_error_msg):
        S3Bucket.read_config('none')
Ejemplo n.º 3
0
def test_read_config(s3git, config_content, branch_name, expected_result):
    with open(S3CONFIG_PATH, 'w') as w:
        w.write(config_content)

    s3_bucket = S3Bucket.read_config(branch_name)

    assert s3_bucket.as_dict == expected_result
Ejemplo n.º 4
0
    def __init__(self,
                 branch: Union[str, None],
                 force_reupload=False,
                 use_wildcard=False):

        self.repo = get_repo()

        # if no branch or revision to sync from was passed,
        # we set to sync from the current branch
        if not branch:
            branch = self.repo.active_branch.name

        # TODO: remove this, it is unused
        self.branch = branch

        self.s3_settings = S3Bucket.read_config(branch)
        self.ignore_list = _retrieve_ignore_list(use_wildcard)

        self.old_tree = self.get_empty_tree() \
            if force_reupload else self.get_remote_tree()
        self.target_tree = self.get_tree(self.repo.commit(branch))