Lower-case rather than upper-case to canonicalize names

Marginally less finicky
This commit is contained in:
Aldo Cortesi 2015-05-03 12:59:21 +12:00
parent 3f5ec4b737
commit 67d2993339
4 changed files with 13 additions and 13 deletions

View File

@ -292,12 +292,12 @@ class OptionsOrValue(_Component):
"""
preamble = ""
def __init__(self, value):
# If it's a string, we were passed one of the options, so we upper-case
# If it's a string, we were passed one of the options, so we lower-case
# it to be canonical. The user can specify a different case by using a
# string value literal.
self.option_used = False
if isinstance(value, basestring):
value = TokValueLiteral(value.upper())
value = TokValueLiteral(value.lower())
self.option_used = True
self.value = value

View File

@ -227,7 +227,7 @@ def test_options_or_value():
"three"
]
e = TT.expr()
assert e.parseString("one")[0].value.val == "ONE"
assert e.parseString("one")[0].value.val == "one"
assert e.parseString("'foo'")[0].value.val == "foo"
assert e.parseString("'get'")[0].value.val == "get"

View File

@ -30,7 +30,7 @@ class TestRequest:
def test_simple(self):
r = parse_request('GET:"/foo"')
assert r.method.string() == "GET"
assert r.method.string() == "get"
assert r.path.string() == "/foo"
r = parse_request('GET:/foo')
assert r.path.string() == "/foo"
@ -39,8 +39,8 @@ class TestRequest:
def test_multiple(self):
r = language.parse_requests("GET:/ PUT:/")
assert r[0].method.string() == "GET"
assert r[1].method.string() == "PUT"
assert r[0].method.string() == "get"
assert r[1].method.string() == "put"
assert len(r) == 2
l = """
@ -60,8 +60,8 @@ class TestRequest:
"""
r = language.parse_requests(l)
assert len(r) == 2
assert r[0].method.string() == "GET"
assert r[1].method.string() == "PUT"
assert r[0].method.string() == "get"
assert r[1].method.string() == "put"
l = """
get:"http://localhost:9999/p/200":ir,@1
@ -69,8 +69,8 @@ class TestRequest:
"""
r = language.parse_requests(l)
assert len(r) == 2
assert r[0].method.string() == "GET"
assert r[1].method.string() == "GET"
assert r[0].method.string() == "get"
assert r[1].method.string() == "get"
def test_pathodspec(self):
l = "get:/p:s'200'"
@ -96,7 +96,7 @@ class TestRequest:
ir,@1
"""
r = parse_request(l)
assert r.method.string() == "GET"
assert r.method.string() == "get"
assert r.path.string() == "/foo"
assert r.actions
@ -112,7 +112,7 @@ class TestRequest:
ir,@1
"""
r = parse_request(l)
assert r.method.string() == "GET"
assert r.method.string() == "get"
assert r.path.string().endswith("bar")
assert r.actions

View File

@ -162,7 +162,7 @@ class TestDaemon(_TestDaemon):
def test_showreq(self):
reqs = ["get:/api/info:p0,0", "get:/api/info:p0,0"]
assert self.tval(reqs, showreq=True).count("GET /api") == 2
assert self.tval(reqs, showreq=True).count("get /api") == 2
assert self.tval(
reqs, showreq=True, hexdump=True
).count("0000000000") == 2