コード例 #1
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_delete_parses_response_json(self):
        self.stub_delete_requests(response_body='{"deleted": true}', )
        client = Client(access_token="abc123")

        response = client.delete("/messages/1")

        self.assertEqual(response.deleted, True)
コード例 #2
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_get_uses_custom_base_url(self):
        self.stub_get_requests()
        client = Client(access_token="1a2bc3", base_url="https://example.com")

        client.get("/messages")

        self.assert_get_request("https://example.com/messages.json")
コード例 #3
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_get_uses_default_base_url(self):
        self.stub_get_requests()
        client = Client(access_token="abc123")

        client.get("/messages")

        self.assert_get_request("https://www.yammer.com/api/v1/messages.json")
コード例 #4
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_delete_handles_success_with_a_blank_body(self):
        self.stub_delete_requests(response_status=200, response_body=" ")
        client = Client(access_token="foobar")

        response = client.delete("/messages/123")

        self.assertEquals(response, True)
コード例 #5
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_delete_handles_success_with_a_blank_body(self):
        self.stub_delete_requests(response_status=200, response_body=" ")
        client = Client(access_token="foobar")

        response = client.delete("/messages/123")

        self.assertEquals(response, True)
コード例 #6
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_put_uses_custom_base_url(self):
        self.stub_put_requests()
        client = Client(access_token="1a2bc3", base_url="http://example.com")

        client.put("/messages", body="Hello fake Yammer")

        self.assert_put_request("http://example.com/messages.json")
コード例 #7
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_put_uses_custom_base_url(self):
        self.stub_put_requests()
        client = Client(access_token="1a2bc3", base_url="http://example.com")

        client.put("/messages", body="Hello fake Yammer")

        self.assert_put_request("http://example.com/messages.json")
コード例 #8
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_get_uses_custom_base_url(self):
        self.stub_get_requests()
        client = Client(access_token="1a2bc3", base_url="https://example.com")

        client.get("/messages")

        self.assert_get_request("https://example.com/messages.json")
コード例 #9
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_put_uses_default_base_url(self):
        self.stub_put_requests()
        client = Client(access_token="abc123")

        client.put("/messages", body="Hello Yammer")

        self.assert_put_request("https://www.yammer.com/api/v1/messages.json")
コード例 #10
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_put_parses_response_json(self):
        self.stub_put_requests(
            response_body='{"messages": ["first", "second"]}', )
        client = Client(access_token="abc123")

        messages = client.put("/messages", body="Hello world")

        self.assertEqual(messages.messages, ["first", "second"])
コード例 #11
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_delete_uses_default_base_url(self):
        self.stub_delete_requests()
        client = Client(access_token="abc123")

        client.delete("/messages/1")

        self.assert_delete_request(
            "https://www.yammer.com/api/v1/messages/1.json")
コード例 #12
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_put_parses_response_json(self):
        self.stub_put_requests(
            response_body='{"messages": ["first", "second"]}',
        )
        client = Client(access_token="abc123")

        messages = client.put("/messages", body="Hello world")

        self.assertEqual(messages.messages, ["first", "second"])
コード例 #13
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_delete_parses_response_json(self):
        self.stub_delete_requests(
            response_body='{"deleted": true}',
        )
        client = Client(access_token="abc123")

        response = client.delete("/messages/1")

        self.assertEqual(response.deleted, True)
コード例 #14
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_delete_sends_query_string_parameters(self):
        self.stub_delete_requests()
        client = Client(access_token="456efg")

        client.delete("/messages/liked_by/current", message_id=12345)

        self.assert_delete_request(
            url="https://www.yammer.com/api/v1/messages/liked_by/current.json",
            params={"message_id": 12345},
        )
コード例 #15
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_get_sends_authorization_header(self):
        self.stub_get_requests()
        client = Client(access_token="abc123")

        client.get("/users/123")

        self.assert_get_request(
            url="https://www.yammer.com/api/v1/users/123.json",
            headers={"Authorization": "Bearer abc123"},
        )
コード例 #16
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_put_sends_authorization_header(self):
        self.stub_put_requests()
        client = Client(access_token="abc123")

        client.put("/messages", body="I am authorized")

        self.assert_put_request(
            url="https://www.yammer.com/api/v1/messages.json",
            headers={"Authorization": "Bearer abc123"},
        )
コード例 #17
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_put_sends_query_string_parameters(self):
        self.stub_put_requests()
        client = Client(access_token="456efg")

        client.put("/messages", body="Oh hai")

        self.assert_put_request(
            url="https://www.yammer.com/api/v1/messages.json",
            params={"body": "Oh hai"},
        )
コード例 #18
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_put_handles_created_responses(self):
        self.stub_put_requests(
            response_status=201,
            response_body='{"status": "OK"}',
        )
        client = Client(access_token="456efg")

        response = client.put("/messages", body="A-OK")

        self.assertEqual(response, {"status": "OK"})
コード例 #19
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_get_does_not_send_authorization_header_with_no_token(self):
        self.stub_get_requests()
        client = Client(access_token=None)

        client.get("/messages")

        self.assert_get_request(
            url="https://www.yammer.com/api/v1/messages.json",
            headers={},
        )
コード例 #20
0
ファイル: client_test.py プロジェクト: dbrattli/yam-python
    def test_get_sends_query_string_parameters(self):
        self.stub_get_requests()
        client = Client(access_token="456efg")

        client.get("/users/by_email", email="*****@*****.**")

        self.assert_get_request(
            url="https://www.yammer.com/api/v1/users/by_email.json",
            params={"email": "*****@*****.**"},
        )
コード例 #21
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_delete_sends_query_string_parameters(self):
        self.stub_delete_requests()
        client = Client(access_token="456efg")

        client.delete("/messages/liked_by/current", message_id=12345)

        self.assert_delete_request(
            url="https://www.yammer.com/api/v1/messages/liked_by/current.json",
            params={"message_id": 12345},
        )
コード例 #22
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_get_does_not_send_authorization_header_with_no_token(self):
        self.stub_get_requests()
        client = Client(access_token=None)

        client.get("/messages")

        self.assert_get_request(
            url="https://www.yammer.com/api/v1/messages.json",
            headers={},
        )
コード例 #23
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_get_sends_query_string_parameters(self):
        self.stub_get_requests()
        client = Client(access_token="456efg")

        client.get("/users/by_email", email="*****@*****.**")

        self.assert_get_request(
            url="https://www.yammer.com/api/v1/users/by_email.json",
            params={"email": "*****@*****.**"},
        )
コード例 #24
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_put_handles_created_responses(self):
        self.stub_put_requests(
            response_status=201,
            response_body='{"status": "OK"}',
        )
        client = Client(access_token="456efg")

        response = client.put("/messages", body="A-OK")

        self.assertEqual(response, {"status": "OK"})
コード例 #25
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_get_sends_authorization_header(self):
        self.stub_get_requests()
        client = Client(access_token="abc123")

        client.get("/users/123")

        self.assert_get_request(
            url="https://www.yammer.com/api/v1/users/123.json",
            headers={"Authorization": "Bearer abc123"},
        )
コード例 #26
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_put_sends_query_string_parameters(self):
        self.stub_put_requests()
        client = Client(access_token="456efg")

        client.put("/messages", body="Oh hai")

        self.assert_put_request(
            url="https://www.yammer.com/api/v1/messages.json",
            params={"body": "Oh hai"},
        )
コード例 #27
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_put_sends_authorization_header(self):
        self.stub_put_requests()
        client = Client(access_token="abc123")

        client.put("/messages", body="I am authorized")

        self.assert_put_request(
            url="https://www.yammer.com/api/v1/messages.json",
            headers={"Authorization": "Bearer abc123"},
        )
コード例 #28
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_post_handles_unexpected_http_responses(self):
        self.stub_post_requests(response_status=122)
        client = Client(access_token="abcdef")

        self.assertRaises(ResponseError,
                          client.post,
                          "/messages",
                          body="BOOM!")
コード例 #29
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_put_handles_rate_limit_error_responses(self):
        self.stub_put_requests(response_status=429)
        client = Client(access_token="abc")

        self.assertRaises(RateLimitExceededError,
                          client.put,
                          "/messages",
                          body="Do I talk too much?")
コード例 #30
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_get_handles_invalid_access_token_responses(self):
        self.stub_get_requests(
            response_status=400,
            response_body="""{
                "error": {
                    "type": "OAuthException",
                    "message": "Error validating access token."
                 }
             }""",
        )
        client = Client(access_token="456efg")

        self.assertRaises(InvalidAccessTokenError, client.get, "/messages")
コード例 #31
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_get_handles_unauthorized_responses(self):
        self.stub_get_requests(response_status=401)
        client = Client(access_token="456efg")

        self.assertRaises(UnauthorizedError, client.get, "/messages")
コード例 #32
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_put_handles_not_found_responses(self):
        self.stub_put_requests(response_status=404)
        client = Client(access_token="456efg")

        self.assertRaises(NotFoundError, client.put, "/not/real")
コード例 #33
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_delete_handles_rate_limit_error_responses(self):
        self.stub_delete_requests(response_status=429)
        client = Client(access_token="abc")

        self.assertRaises(RateLimitExceededError, client.delete, "/user/1")
コード例 #34
0
ファイル: client_test.py プロジェクト: tsgkdt/yampy2
    def test_delete_handles_unexpected_http_responses(self):
        self.stub_delete_requests(response_status=500)
        client = Client(access_token="abcdef")

        self.assertRaises(ResponseError, client.delete, "/messages/1")