Пример #1
0
    def test_related_filters(self):
        """
        Test that we replace related objects with their IDs
        """
        adapter = RepeatingTestAdapter(make_json_response(EMPTY_RESPONSE))
        self.client._session.mount(TEST_ENDPOINT, adapter)

        self.client.measurements.list(related_obj={"id": "5", "arg2": "4"})
        self.client.measurements.list(related_obj={"id": "5"}, other="1")

        r1, r2 = adapter.requests

        self.assertDictEqual({"related_obj": "5"}, extract_qs(r1.url))
        self.assertDictEqual({"related_obj": "5", "other": "1"}, extract_qs(r2.url))
Пример #2
0
    def test_related_filters(self):
        """
        Test that we replace related objects with their IDs
        """
        adapter = RepeatingTestAdapter(make_json_response(EMPTY_RESPONSE))
        self.client._session.mount(TEST_ENDPOINT, adapter)

        self.client.measurements.list(related_obj={"id": "5", "arg2": "4"})
        self.client.measurements.list(related_obj={"id": "5"}, other="1")

        r1, r2 = adapter.requests

        self.assertDictEqual({"related_obj": "5"}, extract_qs(r1.url))
        self.assertDictEqual({
            "related_obj": "5",
            "other": "1"
        }, extract_qs(r2.url))
Пример #3
0
    def test_filters(self):
        """
        Test that arguments are translated as filters
        """

        adapter = RepeatingTestAdapter(make_json_response(EMPTY_RESPONSE))
        self.client._session.mount(TEST_ENDPOINT, adapter)

        self.client.measurements.list()
        self.client.measurements.list(arg1="1", arg2="2")
        self.client.measurements.list(arg1="1", arg2="2", arg3="a")

        r1, r2, r3 = adapter.requests

        self.assertDictEqual({}, extract_qs(r1.url))
        self.assertDictEqual({"arg1": "1", "arg2": "2"}, extract_qs(r2.url))
        self.assertDictEqual({"arg1": "1", "arg2": "2", "arg3": "a"}, extract_qs(r3.url))
Пример #4
0
    def test_filters(self):
        """
        Test that arguments are translated as filters
        """

        adapter = RepeatingTestAdapter(make_json_response(EMPTY_RESPONSE))
        self.client._session.mount(TEST_ENDPOINT, adapter)

        self.client.measurements.list()
        self.client.measurements.list(arg1="1", arg2="2")
        self.client.measurements.list(arg1="1", arg2="2", arg3="a")

        r1, r2, r3 = adapter.requests

        self.assertDictEqual({}, extract_qs(r1.url))
        self.assertDictEqual({"arg1": "1", "arg2": "2"}, extract_qs(r2.url))
        self.assertDictEqual({
            "arg1": "1",
            "arg2": "2",
            "arg3": "a"
        }, extract_qs(r3.url))