Example #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")
Example #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")
Example #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")
Example #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")
Example #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"},
        )
Example #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"},
        )
Example #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"},
        )
Example #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"},
        )
Example #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"])
Example #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"])
Example #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"})
Example #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"})