예제 #1
0
파일: test_client.py 프로젝트: yuanbw/nauta
def test_create_repository_error(requests_mock: Mocker,
                                 git_repo_manager: GitRepoManagerClient):
    repo_name = 'fake_repo'
    get_repo_mock = requests_mock.get(
        f'{git_repo_manager.base_url}/api/v1/repos/{FAKE_USER}/{repo_name}',
        status_code=404)
    post_repo_mock = requests_mock.post(
        f'{git_repo_manager.base_url}/api/v1/admin/users/{FAKE_USER}/repos',
        status_code=422)
    with pytest.raises(HTTPError):
        git_repo_manager.create_repository(username=FAKE_USER,
                                           repository_name=repo_name)

    assert get_repo_mock.call_count == 1
    assert post_repo_mock.call_count == 1
예제 #2
0
파일: test_client.py 프로젝트: yuanbw/nauta
def test_create_repository_exists(requests_mock: Mocker,
                                  git_repo_manager: GitRepoManagerClient):
    repo_name = 'fake_repo'
    get_repo_mock = requests_mock.get(
        f'{git_repo_manager.base_url}/api/v1/repos/{FAKE_USER}/{repo_name}',
        status_code=200)
    post_repo_mock = requests_mock.post(
        f'{git_repo_manager.base_url}/api/v1/admin/users/{FAKE_USER}/repos')
    response = git_repo_manager.create_repository(username=FAKE_USER,
                                                  repository_name=repo_name)

    assert response
    assert get_repo_mock.call_count == 1
    assert post_repo_mock.call_count == 0