Add new uritemplate-test testcases · python-hyper/uritemplate@0ba02f6 · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit 0ba02f6

Browse files
committed
Add new uritemplate-test testcases
This demonstrates the bug in #99
1 parent a56e9ae commit 0ba02f6

File tree

6 files changed

+101
-39
lines changed

6 files changed

+101
-39
lines changed

tests/fixtures/LICENSE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
Copyright 2011- The Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.

tests/fixtures/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
These test are borrowed from https://github.com/uri-templates/uritemplate-test
2-
at commit: fdd5d611a849b922c2ff40fc3997fd265dd14c02
1+
32
URI Template Tests
43
==================
54

65
This is a set of tests for implementations of
7-
[RFC6570](http://tools.ietf.org/html/rfc6570) - URI Template. It is designed
6+
[RFC6570](https://datatracker.ietf.org/doc/html/rfc6570) - URI Template. It is designed
87
to be reused by any implementation, to improve interoperability and
98
implementation quality.
109

tests/fixtures/extended-tests.json

Lines changed: 58 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,8 @@
2828
"testcases":[
2929

3030
[ "{/id*}" , "/person" ],
31-
[ "{/id*}{?fields,first_name,last.name,token}" , [
32-
"/person?fields=id,name,picture&first_name=John&last.name=Doe&token=12345",
33-
"/person?fields=id,picture,name&first_name=John&last.name=Doe&token=12345",
34-
"/person?fields=picture,name,id&first_name=John&last.name=Doe&token=12345",
35-
"/person?fields=picture,id,name&first_name=John&last.name=Doe&token=12345",
36-
"/person?fields=name,picture,id&first_name=John&last.name=Doe&token=12345",
37-
"/person?fields=name,id,picture&first_name=John&last.name=Doe&token=12345"]
38-
],
39-
["/search.{format}{?q,geocode,lang,locale,page,result_type}",
40-
[ "/search.json?q=URI%20Templates&geocode=37.76,-122.427&lang=en&page=5",
41-
"/search.json?q=URI%20Templates&geocode=-122.427,37.76&lang=en&page=5"]
42-
],
31+
[ "{/id*}{?fields,first_name,last.name,token}","/person?fields=id,name,picture&first_name=John&last.name=Doe&token=12345"],
32+
["/search.{format}{?q,geocode,lang,locale,page,result_type}","/search.json?q=URI%20Templates&geocode=37.76,-122.427&lang=en&page=5"],
4333
["/test{/Some%20Thing}", "/test/foo" ],
4434
["/set{?number}", "/set?number=6"],
4535
["/loc{?long,lat}" , "/loc?long=37.76&lat=-122.427"],
@@ -67,21 +57,8 @@
6757
},
6858
"testcases":[
6959

70-
[ "{/id*}" , ["/person/albums","/albums/person"] ],
71-
[ "{/id*}{?fields,token}" , [
72-
"/person/albums?fields=id,name,picture&token=12345",
73-
"/person/albums?fields=id,picture,name&token=12345",
74-
"/person/albums?fields=picture,name,id&token=12345",
75-
"/person/albums?fields=picture,id,name&token=12345",
76-
"/person/albums?fields=name,picture,id&token=12345",
77-
"/person/albums?fields=name,id,picture&token=12345",
78-
"/albums/person?fields=id,name,picture&token=12345",
79-
"/albums/person?fields=id,picture,name&token=12345",
80-
"/albums/person?fields=picture,name,id&token=12345",
81-
"/albums/person?fields=picture,id,name&token=12345",
82-
"/albums/person?fields=name,picture,id&token=12345",
83-
"/albums/person?fields=name,id,picture&token=12345"]
84-
]
60+
[ "{/id*}" , "/person/albums" ],
61+
[ "{/id*}{?fields,token}" , "/person/albums?fields=id,name,picture&token=12345" ]
8562
]
8663
},
8764
"Additional Examples 3: Empty Variables":{
@@ -114,5 +91,59 @@
11491
[ "{?1337*}", "?1337=leet&1337=as&1337=it&1337=can&1337=be"],
11592
[ "{?german*}", [ "?11=elf&12=zw%C3%B6lf", "?12=zw%C3%B6lf&11=elf"] ]
11693
]
94+
},
95+
"Additional Examples 5: Explode Combinations":{
96+
"variables" : {
97+
"id" : "admin",
98+
"token" : "12345",
99+
"tab" : "overview",
100+
"keys" : {
101+
"key1": "val1",
102+
"key2": "val2"
103+
}
104+
},
105+
"testcases":[
106+
[ "{?id,token,keys*}", [
107+
"?id=admin&token=12345&key1=val1&key2=val2",
108+
"?id=admin&token=12345&key2=val2&key1=val1"]
109+
],
110+
[ "{/id}{?token,keys*}", [
111+
"/admin?token=12345&key1=val1&key2=val2",
112+
"/admin?token=12345&key2=val2&key1=val1"]
113+
],
114+
[ "{?id,token}{&keys*}", [
115+
"?id=admin&token=12345&key1=val1&key2=val2",
116+
"?id=admin&token=12345&key2=val2&key1=val1"]
117+
],
118+
[ "/user{/id}{?token,tab}{&keys*}", [
119+
"/user/admin?token=12345&tab=overview&key1=val1&key2=val2",
120+
"/user/admin?token=12345&tab=overview&key2=val2&key1=val1"]
121+
]
122+
]
123+
},
124+
"Additional Examples 6: Reserved Expansion":{
125+
"variables" : {
126+
"id" : "admin%2F",
127+
"not_pct" : "%foo",
128+
"list" : ["red%25", "%2Fgreen", "blue "],
129+
"keys" : {
130+
"key1": "val1%2F",
131+
"key2": "val2%2F"
132+
}
133+
},
134+
"testcases": [
135+
["{+id}", "admin%2F"],
136+
["{#id}", "#admin%2F"],
137+
["{id}", "admin%252F"],
138+
["{+not_pct}", "%25foo"],
139+
["{#not_pct}", "#%25foo"],
140+
["{not_pct}", "%25foo"],
141+
["{+list}", "red%25,%2Fgreen,blue%20"],
142+
["{#list}", "#red%25,%2Fgreen,blue%20"],
143+
["{list}", "red%2525,%252Fgreen,blue%20"],
144+
["{+keys}", "key1,val1%2F,key2,val2%2F"],
145+
["{#keys}", "#key1,val1%2F,key2,val2%2F"],
146+
["{keys}", "key1,val1%252F,key2,val2%252F"]
147+
]
117148
}
118149
}

tests/fixtures/spec-examples-by-section.json

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
2+
"2.1 Literals" :
3+
{
4+
"variables": {
5+
"count" : ["one", "two", "three"]
6+
},
7+
"testcases" : [
8+
["'{count}'", "'one,two,three'"]
9+
]
10+
},
211
"3.2.1 Variable Expansion" :
312
{
413
"variables": {
@@ -17,7 +26,7 @@
1726
"x" : "1024",
1827
"y" : "768",
1928
"empty" : "",
20-
"empty_keys" : [],
29+
"empty_keys" : {},
2130
"undef" : null
2231
},
2332
"testcases" : [
@@ -50,7 +59,7 @@
5059
"x" : "1024",
5160
"y" : "768",
5261
"empty" : "",
53-
"empty_keys" : [],
62+
"empty_keys" : {},
5463
"undef" : null
5564
},
5665
"testcases" : [
@@ -104,7 +113,7 @@
104113
"x" : "1024",
105114
"y" : "768",
106115
"empty" : "",
107-
"empty_keys" : [],
116+
"empty_keys" : {},
108117
"undef" : null
109118
},
110119
"testcases" : [
@@ -161,7 +170,7 @@
161170
"x" : "1024",
162171
"y" : "768",
163172
"empty" : "",
164-
"empty_keys" : [],
173+
"empty_keys" : {},
165174
"undef" : null
166175
},
167176
"testcases" : [
@@ -203,7 +212,7 @@
203212
"x" : "1024",
204213
"y" : "768",
205214
"empty" : "",
206-
"empty_keys" : [],
215+
"empty_keys" : {},
207216
"undef" : null
208217
},
209218
"testcases" : [
@@ -255,7 +264,7 @@
255264
"x" : "1024",
256265
"y" : "768",
257266
"empty" : "",
258-
"empty_keys" : [],
267+
"empty_keys" : {},
259268
"undef" : null
260269
},
261270
"testcases" : [
@@ -307,7 +316,7 @@
307316
"x" : "1024",
308317
"y" : "768",
309318
"empty" : "",
310-
"empty_keys" : [],
319+
"empty_keys" : {},
311320
"undef" : null
312321
},
313322
"testcases" : [
@@ -358,7 +367,7 @@
358367
"x" : "1024",
359368
"y" : "768",
360369
"empty" : "",
361-
"empty_keys" : [],
370+
"empty_keys" : {},
362371
"undef" : null
363372
},
364373
"testcases" : [
@@ -406,7 +415,7 @@
406415
"x" : "1024",
407416
"y" : "768",
408417
"empty" : "",
409-
"empty_keys" : [],
418+
"empty_keys" : {},
410419
"undef" : null
411420
},
412421
"testcases" : [

tests/fixtures/spec-examples.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"testcases" : [
1010
["{var}", "value"],
11+
["'{var}'", "'value'"],
1112
["{hello}", "Hello%20World%21"]
1213
]
1314
},

tests/test_from_fixtures.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,11 @@ def test_additional_examples_3(self) -> None:
134134
def test_additional_examples_4(self) -> None:
135135
"""Check Additional Examples 4."""
136136
self._test("Additional Examples 4: Numeric Keys")
137+
138+
def test_additional_examples_5(self) -> None:
139+
"""Check Additional Examples 5."""
140+
self._test("Additional Examples 5: Explode Combinations")
141+
142+
def test_additional_examples_6(self) -> None:
143+
"""Check Additional Examples 6."""
144+
self._test("Additional Examples 6: Reserved Expansion")

0 commit comments

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.