def test_get_user_profile_whit_errors():
    with pytest.raises(exc.GitHubApiError) as e, \
            patch("taiga.base.connectors.github.requests") as m_requests:
        m_requests.get.return_value = m_response = Mock()
        m_response.status_code = 401
        m_response.json.return_value = {"error": "Invalid credentials"}

        auth_info = github.get_user_profile(github.HEADERS)
    assert e.value.status_code == 400
    assert e.value.detail["status_code"] == 401
    assert e.value.detail["error"] == "Invalid credentials"
Exemple #2
0
def test_get_user_profile_whit_errors():
    with pytest.raises(exc.GitHubApiError) as e, \
            patch("taiga.base.connectors.github.requests") as m_requests:
        m_requests.get.return_value = m_response = Mock()
        m_response.status_code = 401
        m_response.json.return_value = {"error": "Invalid credentials"}

        auth_info = github.get_user_profile(github.HEADERS)
    assert e.value.status_code == 400
    assert e.value.detail["status_code"] == 401
    assert e.value.detail["error"] == "Invalid credentials"
def test_get_user_profile_success():
    with patch("taiga.base.connectors.github.requests") as m_requests:
        m_requests.get.return_value = m_response = Mock()
        m_response.status_code = 200
        m_response.json.return_value = {"id": 1955,
                                        "login": "******",
                                        "name": "martin seamus mcfly",
                                        "bio": "time traveler"}

        user_profile = github.get_user_profile(github.HEADERS)

        assert user_profile.id == 1955
        assert user_profile.username == "mmcfly"
        assert user_profile.full_name == "martin seamus mcfly"
        assert user_profile.bio == "time traveler"
        m_requests.get.assert_called_once_with("https://api.github.com/user",
                                               headers=github.HEADERS)
Exemple #4
0
def test_get_user_profile_success():
    with patch("taiga.base.connectors.github.requests") as m_requests:
        m_requests.get.return_value = m_response = Mock()
        m_response.status_code = 200
        m_response.json.return_value = {"id": 1955,
                                        "login": "******",
                                        "name": "martin seamus mcfly",
                                        "bio": "time traveler"}

        user_profile = github.get_user_profile(github.HEADERS)

        assert user_profile.id == 1955
        assert user_profile.username == "mmcfly"
        assert user_profile.full_name == "martin seamus mcfly"
        assert user_profile.bio == "time traveler"
        m_requests.get.assert_called_once_with("https://api.github.com/user",
                                               headers=github.HEADERS)