def test_get_by_username_when_empty_list_returns_raises_user_not_exists( self, mock_session, mock_get_users_empty_response): mock_session.get.return_value = mock_get_users_empty_response client = UserClient(mock_session) with pytest.raises(Py42UserDoesNotExistError) as err: client.get_by_username("username") assert str(err.value) == "User 'username' does not exist."
def test_unicode_username_get_user_by_username_calls_get_with_username( self, mock_session, successful_response): username = u"您已经发现了秘密信息" mock_session.get.return_value = successful_response client = UserClient(mock_session) client.get_by_username(username) expected_params = {u"username": username} mock_session.get.assert_called_once_with(USER_URI, params=expected_params)