Ejemplo n.º 1
0
def test_create_library_revision(client_mock, config):
    """Create a new library revision in the store."""
    test_charm_name = "test-charm-name"
    test_lib_name = "test-lib-name"
    test_lib_id = "test-lib-id"
    test_api = "test-api-version"
    test_patch = "test-patch-version"
    test_content = "test content with quite a lot of funny Python code :p"
    test_hash = "1234"

    store = Store(config.charmhub)
    client_mock.post.return_value = {
        "api": test_api,
        "content": test_content,
        "hash": test_hash,
        "library-id": test_lib_id,
        "library-name": test_lib_name,
        "charm-name": test_charm_name,
        "patch": test_patch,
    }

    result_lib = store.create_library_revision(test_charm_name, test_lib_id,
                                               test_api, test_patch,
                                               test_content, test_hash)

    payload = {
        "api": test_api,
        "patch": test_patch,
        "content": test_content,
        "hash": test_hash,
    }
    assert client_mock.mock_calls == [
        call.post("/v1/charm/libraries/test-charm-name/" + test_lib_id,
                  payload),
    ]
    assert result_lib.api == test_api
    assert result_lib.content == test_content
    assert result_lib.content_hash == test_hash
    assert result_lib.lib_id == test_lib_id
    assert result_lib.lib_name == test_lib_name
    assert result_lib.charm_name == test_charm_name
    assert result_lib.patch == test_patch
Ejemplo n.º 2
0
def test_create_library_revision(client_mock):
    """Create a new library revision in the store."""
    test_charm_name = 'test-charm-name'
    test_lib_name = 'test-lib-name'
    test_lib_id = 'test-lib-id'
    test_api = 'test-api-version'
    test_patch = 'test-patch-version'
    test_content = 'test content with quite a lot of funny Python code :p'
    test_hash = '1234'

    store = Store()
    client_mock.post.return_value = {
        'api': test_api,
        'content': test_content,
        'hash': test_hash,
        'library-id': test_lib_id,
        'library-name': test_lib_name,
        'charm-name': test_charm_name,
        'patch': test_patch,
    }

    result_lib = store.create_library_revision(test_charm_name, test_lib_id,
                                               test_api, test_patch,
                                               test_content, test_hash)

    payload = {
        'api': test_api,
        'patch': test_patch,
        'content': test_content,
        'hash': test_hash,
    }
    assert client_mock.mock_calls == [
        call.post('/v1/charm/libraries/test-charm-name/' + test_lib_id,
                  payload),
    ]
    assert result_lib.api == test_api
    assert result_lib.content == test_content
    assert result_lib.content_hash == test_hash
    assert result_lib.lib_id == test_lib_id
    assert result_lib.lib_name == test_lib_name
    assert result_lib.charm_name == test_charm_name
    assert result_lib.patch == test_patch