Example #1
0
    def test_prepare_uri_absolute_url_with_query(self):
        """ Test that absolute URLs get generated correctly with query param """
        path = "http://www.baseurl.com/something"
        query_params = {"key1": "val1", "key2": "val2"}
        expected_uri = path + "?" + urllib.urlencode(query_params, True)

        fw = Framework()
        self.assertEqual(fw._prepare_uri(path, query_params), expected_uri)
Example #2
0
    def test_prepare_uri_relative_url_no_query(self):
        """ Test that relative URLs get generated correctly with no query param """
        base_url = "https://someurl:443"
        path = "/something"
        expected_uri = "".join((base_url, path))

        fw = Framework(base_url)
        self.assertEqual(fw._prepare_uri(path), expected_uri)
Example #3
0
    def test_prepare_uri_relative_url_with_query(self):
        """ Test that relative URLs get generated correctly with a query param """
        base_url = "https://someurl:443"
        path = "/something"
        query_params = {"key1": "val1", "key2": "val2"}
        expected_uri = "".join((base_url, path)) + "?" + urllib.urlencode(query_params, True)


        fw = Framework(base_url)
        self.assertEqual(fw._prepare_uri(path, query_params), expected_uri)
Example #4
0
    def test_prepare_uri_absolute_url_no_query(self):
        """ Test that absolute URLs get generated correctly with no query param """
        path = "http://www.baseurl.com/something"

        fw = Framework()
        self.assertEqual(fw._prepare_uri(path), path)