Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: recipe_engine/third_party/requests/tests/test_structures.py

Issue 2164713003: Vendor requests. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: Fix deps.pyl Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # coding: utf-8
2 import pytest
3
4 from requests.structures import CaseInsensitiveDict, LookupDict
5
6
7 class TestCaseInsensitiveDict:
8
9 @pytest.fixture(autouse=True)
10 def setup(self):
11 """
12 CaseInsensitiveDict instance with "Accept" header.
13 """
14 self.case_insensitive_dict = CaseInsensitiveDict()
15 self.case_insensitive_dict['Accept'] = 'application/json'
16
17 def test_list(self):
18 assert list(self.case_insensitive_dict) == ['Accept']
19
20 possible_keys = pytest.mark.parametrize('key', ('accept', 'ACCEPT', 'aCcEpT' , 'Accept'))
21
22 @possible_keys
23 def test_getitem(self, key):
24 assert self.case_insensitive_dict[key] == 'application/json'
25
26 @possible_keys
27 def test_delitem(self, key):
28 del self.case_insensitive_dict[key]
29 assert key not in self.case_insensitive_dict
30
31 def test_lower_items(self):
32 assert list(self.case_insensitive_dict.lower_items()) == [('accept', 'ap plication/json')]
33
34 def test_repr(self):
35 assert repr(self.case_insensitive_dict) == "{'Accept': 'application/json '}"
36
37 def test_copy(self):
38 copy = self.case_insensitive_dict.copy()
39 assert copy is not self.case_insensitive_dict
40 assert copy == self.case_insensitive_dict
41
42 @pytest.mark.parametrize(
43 'other, result', (
44 ({'AccePT': 'application/json'}, True),
45 ({}, False),
46 (None, False)
47 )
48 )
49 def test_instance_equality(self, other, result):
50 assert (self.case_insensitive_dict == other) is result
51
52
53 class TestLookupDict:
54
55 @pytest.fixture(autouse=True)
56 def setup(self):
57 """
58 LookupDict instance with "bad_gateway" attribute.
59 """
60 self.lookup_dict = LookupDict('test')
61 self.lookup_dict.bad_gateway = 502
62
63 def test_repr(self):
64 assert repr(self.lookup_dict) == "<lookup 'test'>"
65
66 get_item_parameters = pytest.mark.parametrize(
67 'key, value', (
68 ('bad_gateway', 502),
69 ('not_a_key', None)
70 )
71 )
72
73 @get_item_parameters
74 def test_getitem(self, key, value):
75 assert self.lookup_dict[key] == value
76
77 @get_item_parameters
78 def test_get(self, key, value):
79 assert self.lookup_dict.get(key) == value
OLDNEW
« no previous file with comments | « recipe_engine/third_party/requests/tests/test_requests.py ('k') | recipe_engine/third_party/requests/tests/test_testserver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698