Exemple #1
0
def test_create_repository(repo_type, response, repository_collection, faker,
                           mocker):
    """
    Ensure the delete method verifies the groovy script is in place and runs it
    with the configuration for the repository to be created as argument. Also
    test that the result is correctly interpreted for success/failure.
    """
    x_configuration = faker.pydict()
    repository_collection.client.scripts.run.return_value = response

    mocker.patch('json.dumps')
    json.dumps.return_value = x_configuration

    mocker.patch.object(repository.Repository,
                        'configuration',
                        new_callable=mocker.PropertyMock,
                        return_value=x_configuration)

    repo = repository.Repository(repo_type)

    if response.get('result') == 'null':
        repository_collection.create(repo)
    else:
        with pytest.raises(exception.NexusClientCreateRepositoryError):
            repository_collection.create(repo)

    repository_collection.client.scripts.create_if_missing.assert_called_once()
    json.dumps.assert_called_with(repo.configuration)
    repository_collection.client.scripts.run.assert_called_with(
        'nexus3-cli-repository-create', data=json.dumps.return_value)
Exemple #2
0
def test_create_repository_error(repo_type, repository_collection, mocker):
    mocker.patch('json.dumps')
    mocker.patch.object(repository.Repository,
                        'configuration',
                        new_callable=mocker.PropertyMock)

    repo = repository.Repository(repo_type)

    with pytest.raises(exception.NexusClientCreateRepositoryError):
        repository_collection.create(repo)
Exemple #3
0
def cmd_repo_create(nexus_client, args):
    """Performs ``rekt repo create *`` commands"""
    r = repository.Repository(
        args_to_repo_type(args),
        ignore_extra_kwargs=True,
        name=args.get('<repo_name>'),
        format=args_to_repo_format(args),
        blob_store_name=args.get('--blob'),
        depth=int(args.get('--depth')),
        remote_url=args.get('<remote_url>'),
        strict_content_type_validation=args.get('--strict-content'),
        version_policy=args.get('--version'),
        write_policy=args.get('--write'),
        layout_policy=args.get('--layout'),
    )
    nexus_client.repositories.create(r)