How to use uritemplate - 10 common examples

To help you get started, we’ve selected a few uritemplate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-hyper / uritemplate / test_uritemplate.py View on Github external
def test_list_test(self):
        l = [1, 2, 3, 4]
        self.assertEqual(variable.list_test(l), True)

        l = str([1, 2, 3, 4])
        self.assertEqual(variable.list_test(l), False)
github python-hyper / uritemplate / test_uritemplate.py View on Github external
def test_list_of_tuples_test(self):
        l = [(1, 2), (3, 4)]
        self.assertEqual(variable.dict_test(l), False)

        d = dict(l)
        self.assertEqual(variable.dict_test(d), True)
github python-hyper / uritemplate / test_uritemplate.py View on Github external
def test_list_of_tuples_test(self):
        l = [(1, 2), (3, 4)]
        self.assertEqual(variable.dict_test(l), False)

        d = dict(l)
        self.assertEqual(variable.dict_test(d), True)
github python-hyper / uritemplate / test_uritemplate.py View on Github external
def test_list_test(self):
        l = [1, 2, 3, 4]
        self.assertEqual(variable.list_test(l), True)

        l = str([1, 2, 3, 4])
        self.assertEqual(variable.list_test(l), False)
github github / octokit.py / tests / test_resources.py View on Github external
def test_httpverb(self):
        """Test that each HTTP verb works properly when JSON is returned."""
        verbs_to_methods = [
            ('GET', self.client.get),
            ('POST', self.client.post),
            ('PUT', self.client.put),
            ('PATCH', self.client.patch),
            ('DELETE', self.client.delete),
            ('HEAD', self.client.head),
            ('OPTIONS', self.client.options),
        ]

        for verb, method in verbs_to_methods:
            url = uritemplate.expand(self.client.url, {'param': 'foo'})
            self.adapter.register_uri(verb, url, text='{"success": true}')

            response = method(param='foo')
            assert response.success

            # test named param inference
            response = method('foo')
            assert response.success
github python-hyper / uritemplate / test_uritemplate.py View on Github external
def test_default_value(self):
        uri = 'https://api.github.com/user{/user=sigmavirus24}'
        t = URITemplate(uri)
        self.assertEqual(t.expand(),
                         'https://api.github.com/user/sigmavirus24')
        self.assertEqual(t.expand(user='lukasa'),
                         'https://api.github.com/user/lukasa')
github python-hyper / uritemplate / test_uritemplate.py View on Github external
def setUp(self):
        self.v = variable.URIVariable('{foo}')
github python-hyper / uritemplate / test_uritemplate.py View on Github external
def test_post_parse_plus(self):
        v = self.v
        v.operator = '+'
        v.post_parse()
        self.assertEqual(v.join_str, ',')
        self.assertEqual(v.safe, variable.URIVariable.reserved)
        self.assertEqual(v.start, '')
github python-hyper / uritemplate / test_uritemplate.py View on Github external
def test_post_parse_octothorpe(self):
        v = self.v
        v.operator = '#'
        v.post_parse()
        self.assertEqual(v.join_str, ',')
        self.assertEqual(v.safe, variable.URIVariable.reserved)
        self.assertEqual(v.start, '#')
github python-hyper / uritemplate / test_uritemplate.py View on Github external
def test_is_list_of_tuples(self):
        l = [(1, 2), (3, 4)]
        self.assertEqual(variable.is_list_of_tuples(l), (True, l))

        l = [1, 2, 3, 4]
        self.assertEqual(variable.is_list_of_tuples(l), (False, None))