diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-01-08 04:14:01 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-01-08 04:14:01 +0000 |
commit | ae64a5137d25bf9beccd327013e79947c0dedca5 (patch) | |
tree | 6072009c262a4bd31720d0c97d20d3a5dbffbb0c /tests | |
parent | 764152291ebe8baeb008709001503a005fb8905f (diff) | |
parent | e9b8a40534df1b0de66ee1d6581ce657a6f9eee9 (diff) | |
download | uritemplates-ae64a5137d25bf9beccd327013e79947c0dedca5.tar.gz |
Snap for 6118234 from e9b8a40534df1b0de66ee1d6581ce657a6f9eee9 to rvc-releaseandroid-vts-11.0_r9android-vts-11.0_r8android-vts-11.0_r7android-vts-11.0_r6android-vts-11.0_r5android-vts-11.0_r4android-vts-11.0_r3android-vts-11.0_r2android-vts-11.0_r16android-vts-11.0_r15android-vts-11.0_r14android-vts-11.0_r13android-vts-11.0_r12android-vts-11.0_r11android-vts-11.0_r10android-vts-11.0_r1android-security-11.0.0_r76android-security-11.0.0_r75android-security-11.0.0_r74android-security-11.0.0_r73android-security-11.0.0_r72android-security-11.0.0_r71android-security-11.0.0_r70android-security-11.0.0_r69android-security-11.0.0_r68android-security-11.0.0_r67android-security-11.0.0_r66android-security-11.0.0_r65android-security-11.0.0_r64android-security-11.0.0_r63android-security-11.0.0_r62android-security-11.0.0_r61android-security-11.0.0_r60android-security-11.0.0_r59android-security-11.0.0_r58android-security-11.0.0_r57android-security-11.0.0_r56android-security-11.0.0_r55android-security-11.0.0_r54android-security-11.0.0_r53android-security-11.0.0_r52android-security-11.0.0_r51android-security-11.0.0_r50android-security-11.0.0_r49android-security-11.0.0_r1android-platform-11.0.0_r9android-platform-11.0.0_r8android-platform-11.0.0_r7android-platform-11.0.0_r6android-platform-11.0.0_r5android-platform-11.0.0_r40android-platform-11.0.0_r4android-platform-11.0.0_r39android-platform-11.0.0_r38android-platform-11.0.0_r37android-platform-11.0.0_r36android-platform-11.0.0_r35android-platform-11.0.0_r34android-platform-11.0.0_r33android-platform-11.0.0_r32android-platform-11.0.0_r31android-platform-11.0.0_r30android-platform-11.0.0_r3android-platform-11.0.0_r29android-platform-11.0.0_r28android-platform-11.0.0_r27android-platform-11.0.0_r26android-platform-11.0.0_r25android-platform-11.0.0_r24android-platform-11.0.0_r23android-platform-11.0.0_r22android-platform-11.0.0_r21android-platform-11.0.0_r20android-platform-11.0.0_r2android-platform-11.0.0_r19android-platform-11.0.0_r18android-platform-11.0.0_r17android-platform-11.0.0_r16android-platform-11.0.0_r15android-platform-11.0.0_r14android-platform-11.0.0_r13android-platform-11.0.0_r12android-platform-11.0.0_r11android-platform-11.0.0_r10android-platform-11.0.0_r1android-cts-11.0_r9android-cts-11.0_r8android-cts-11.0_r7android-cts-11.0_r6android-cts-11.0_r5android-cts-11.0_r4android-cts-11.0_r3android-cts-11.0_r2android-cts-11.0_r16android-cts-11.0_r15android-cts-11.0_r14android-cts-11.0_r13android-cts-11.0_r12android-cts-11.0_r11android-cts-11.0_r10android-cts-11.0_r1android-11.0.0_r6android-11.0.0_r5android-11.0.0_r4android-11.0.0_r3android-11.0.0_r25android-11.0.0_r2android-11.0.0_r17android-11.0.0_r1android11-tests-releaseandroid11-security-releaseandroid11-s1-releaseandroid11-releaseandroid11-platform-releaseandroid11-gsi
Change-Id: Ie30eb8d343aebfc67126d44dbb4d5885d7066484
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fixtures/extended-tests.json | 6 | ||||
-rw-r--r-- | tests/test_from_fixtures.py | 5 | ||||
-rw-r--r-- | tests/test_uritemplate.py | 68 |
3 files changed, 63 insertions, 16 deletions
diff --git a/tests/fixtures/extended-tests.json b/tests/fixtures/extended-tests.json index fd69744..ad43ad6 100644 --- a/tests/fixtures/extended-tests.json +++ b/tests/fixtures/extended-tests.json @@ -11,7 +11,7 @@ "lang" : "en", "geocode" : ["37.76","-122.427"], "first_name" : "John", - "last.name" : "Doe", + "last.name" : "Doe", "Some%20Thing" : "foo", "number" : 6, "long" : 37.76, @@ -28,7 +28,7 @@ "testcases":[ [ "{/id*}" , "/person" ], - [ "{/id*}{?fields,first_name,last.name,token}" , [ + [ "{/id*}{?fields,first_name,last.name,token}" , [ "/person?fields=id,name,picture&first_name=John&last.name=Doe&token=12345", "/person?fields=id,picture,name&first_name=John&last.name=Doe&token=12345", "/person?fields=picture,name,id&first_name=John&last.name=Doe&token=12345", @@ -68,7 +68,7 @@ "testcases":[ [ "{/id*}" , ["/person/albums","/albums/person"] ], - [ "{/id*}{?fields,token}" , [ + [ "{/id*}{?fields,token}" , [ "/person/albums?fields=id,name,picture&token=12345", "/person/albums?fields=id,picture,name&token=12345", "/person/albums?fields=picture,name,id&token=12345", diff --git a/tests/test_from_fixtures.py b/tests/test_from_fixtures.py index 70d6553..d6c9810 100644 --- a/tests/test_from_fixtures.py +++ b/tests/test_from_fixtures.py @@ -1,3 +1,4 @@ +import io import json import os.path @@ -12,7 +13,7 @@ def fixture_file_path(filename): def load_examples(filename): path = fixture_file_path(filename) - with open(path, 'r') as examples_file: + with io.open(path, 'r', encoding="utf-8") as examples_file: examples = json.load(examples_file) return examples @@ -20,7 +21,7 @@ def load_examples(filename): def expected_set(expected): if isinstance(expected, list): return set(expected) - return set([expected]) + return {expected} class FixtureMixin(object): diff --git a/tests/test_uritemplate.py b/tests/test_uritemplate.py index b1abc96..f67ad26 100644 --- a/tests/test_uritemplate.py +++ b/tests/test_uritemplate.py @@ -464,6 +464,52 @@ class TestURITemplate(RFCTemplateExamples('RFCMeta', (TestCase,), {})): None ) + def test_label_path_expansion_explode_slash(self): + t = URITemplate('{/foo*}') + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', [], True, '/'), None + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', [None], True, '/'), None + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', [None, None], True, '/'), None + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', ['one'], True, '/'), 'one' + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', ['one', 'two'], True, '/'), 'one/two' + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', ['one', None, 'two'], True, '/'), 'one/two' + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', [''], True, '/'), '' + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', ['', ''], True, '/'), '/' + ) + + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', {}, True, '/'), None + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', {'one': ''}, True, '/'), 'one=' + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', {'one': '', 'two': ''}, True, '/'), 'one=/two=' + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', {'one': None}, True, '/'), None + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', {'one': None, 'two': 'two'}, True, '/'), 'two=two' + ) + self.assertEqual(t.variables[0]._label_path_expansion( + 'foo', {'one': None, 'two': None}, True, '/'), None + ) + def test_semi_path_expansion(self): t = URITemplate('{foo}') v = t.variables[0] @@ -544,24 +590,24 @@ class TestURIVariable(TestCase): class TestVariableModule(TestCase): def test_is_list_of_tuples(self): - l = [(1, 2), (3, 4)] - self.assertEqual(variable.is_list_of_tuples(l), (True, l)) + a_list = [(1, 2), (3, 4)] + self.assertEqual(variable.is_list_of_tuples(a_list), (True, a_list)) - l = [1, 2, 3, 4] - self.assertEqual(variable.is_list_of_tuples(l), (False, None)) + a_list = [1, 2, 3, 4] + self.assertEqual(variable.is_list_of_tuples(a_list), (False, None)) def test_list_test(self): - l = [1, 2, 3, 4] - self.assertEqual(variable.list_test(l), True) + a_list = [1, 2, 3, 4] + self.assertEqual(variable.list_test(a_list), True) - l = str([1, 2, 3, 4]) - self.assertEqual(variable.list_test(l), False) + a_list = str([1, 2, 3, 4]) + self.assertEqual(variable.list_test(a_list), False) def test_list_of_tuples_test(self): - l = [(1, 2), (3, 4)] - self.assertEqual(variable.dict_test(l), False) + a_list = [(1, 2), (3, 4)] + self.assertEqual(variable.dict_test(a_list), False) - d = dict(l) + d = dict(a_list) self.assertEqual(variable.dict_test(d), True) |