Esempio n. 1
0
    def test_post_uses_default_base_url(self):
        self.stub_post_requests()
        client = Client(access_token="abc123")

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

        self.assert_post_request("https://www.yammer.com/api/v1/messages.json")
Esempio n. 2
0
    def test_post_uses_custom_base_url(self):
        self.stub_post_requests()
        client = Client(access_token="1a2bc3", base_url="http://example.com")

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

        self.assert_post_request("http://example.com/messages.json")
Esempio n. 3
0
    def test_post_uses_custom_base_url(self):
        self.stub_post_requests()
        client = Client(access_token="1a2bc3", base_url="http://example.com")

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

        self.assert_post_request("http://example.com/messages.json")
Esempio n. 4
0
    def test_post_uses_default_base_url(self):
        self.stub_post_requests()
        client = Client(access_token="abc123")

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

        self.assert_post_request("https://www.yammer.com/api/v1/messages.json")
Esempio n. 5
0
    def test_post_sends_query_string_parameters(self):
        self.stub_post_requests()
        client = Client(access_token="456efg")

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

        self.assert_post_request(
            url="https://www.yammer.com/api/v1/messages.json",
            params={"body": "Oh hai"},
        )
Esempio n. 6
0
    def test_post_sends_authorization_header(self):
        self.stub_post_requests()
        client = Client(access_token="abc123")

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

        self.assert_post_request(
            url="https://www.yammer.com/api/v1/messages.json",
            headers={"Authorization": "Bearer abc123"},
        )
Esempio n. 7
0
    def test_post_sends_query_string_parameters(self):
        self.stub_post_requests()
        client = Client(access_token="456efg")

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

        self.assert_post_request(
            url="https://www.yammer.com/api/v1/messages.json",
            params={"body": "Oh hai"},
        )
Esempio n. 8
0
    def test_post_sends_authorization_header(self):
        self.stub_post_requests()
        client = Client(access_token="abc123")

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

        self.assert_post_request(
            url="https://www.yammer.com/api/v1/messages.json",
            headers={"Authorization": "Bearer abc123"},
        )
Esempio n. 9
0
    def test_post_parses_response_json(self):
        self.stub_post_requests(
            response_body='{"messages": ["first", "second"]}', )
        client = Client(access_token="abc123")

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

        self.assertEqual(messages.messages, ["first", "second"])
Esempio n. 10
0
    def test_post_parses_response_json(self):
        self.stub_post_requests(
            response_body='{"messages": ["first", "second"]}',
        )
        client = Client(access_token="abc123")

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

        self.assertEqual(messages.messages, ["first", "second"])
Esempio n. 11
0
    def test_post_handles_created_responses(self):
        self.stub_post_requests(
            response_status=201,
            response_body='{"status": "OK"}',
        )
        client = Client(access_token="456efg")

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

        self.assertEqual(response, {"status": "OK"})
Esempio n. 12
0
    def test_post_handles_created_responses(self):
        self.stub_post_requests(
            response_status=201,
            response_body='{"status": "OK"}',
        )
        client = Client(access_token="456efg")

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

        self.assertEqual(response, {"status": "OK"})