Skip to content

Commit

Permalink
Add getter keys() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hasier committed Jan 11, 2023
1 parent 5980395 commit c219bb0
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@


class TestASGIGetter(TestCase):
def test_get_none(self):
def test_get_none_empty_carrier(self):
getter = ASGIGetter()
carrier = {}
val = getter.get(carrier, "test")
self.assertIsNone(val)

def test_get_none_empty_headers(self):
getter = ASGIGetter()
carrier = {"headers": []}
val = getter.get(carrier, "test")
self.assertIsNone(val)

def test_get_(self):
getter = ASGIGetter()
carrier = {"headers": [(b"test-key", b"val")]}
Expand All @@ -44,7 +50,22 @@ def test_get_(self):
"Should be case insensitive",
)

def test_keys(self):
def test_keys_empty_carrier(self):
getter = ASGIGetter()
keys = getter.keys({})
self.assertEqual(keys, [])

def test_keys_empty_headers(self):
getter = ASGIGetter()
keys = getter.keys({"headers": []})
self.assertEqual(keys, [])

def test_keys(self):
getter = ASGIGetter()
carrier = {"headers": [(b"test-key", b"val")]}
expected_val = ["test-key"]
self.assertEqual(
getter.keys(carrier),
expected_val,
"Should be equal",
)

0 comments on commit c219bb0

Please sign in to comment.