Skip to content

Commit 9a46d0e

Browse files
committed
Black reformatting.
1 parent 6b2b080 commit 9a46d0e

File tree

10 files changed

+203
-134
lines changed

10 files changed

+203
-134
lines changed

dev/notdatadog.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616

1717

1818
class AsyncoreSocketUDP(asyncore.dispatcher):
19-
20-
def __init__(self, host='127.0.0.1', port=8125):
19+
def __init__(self, host="127.0.0.1", port=8125):
2120
asyncore.dispatcher.__init__(self)
2221
self.create_socket(socket.AF_INET, socket.SOCK_DGRAM)
23-
print(f'Listening on udp {host}:{port}')
22+
print(f"Listening on udp {host}:{port}")
2423
self.bind((host, port))
2524

2625
def handle_connect(self):
@@ -37,9 +36,7 @@ def writable(self):
3736
return False
3837

3938

40-
if __name__ == '__main__':
39+
if __name__ == "__main__":
4140
options = smtpd.parseargs()
42-
AsyncoreSocketUDP(
43-
options.localhost, options.localport,
44-
)
41+
AsyncoreSocketUDP(options.localhost, options.localport)
4542
asyncore.loop()

dev/smtp.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@
1616

1717

1818
class DebuggingServer(smtpd.SMTPServer):
19-
2019
def process_message(self, peer, mailfrom, rcpttos, data, **kwargs):
21-
print('---------- MESSAGE FOLLOWS ----------')
20+
print("---------- MESSAGE FOLLOWS ----------")
2221
print(quopri.decodestring(data).decode())
23-
print('------------ END MESSAGE ------------')
22+
print("------------ END MESSAGE ------------")
2423

2524

26-
if __name__ == '__main__':
25+
if __name__ == "__main__":
2726
options = smtpd.parseargs()
2827
DebuggingServer(
29-
(options.localhost, options.localport),
30-
(options.remotehost, options.remoteport),
28+
(options.localhost, options.localport), (options.remotehost, options.remoteport)
3129
)
3230
asyncore.loop()

docs/conf.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@
2828
# Add any Sphinx extension module names here, as strings. They can be
2929
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3030
# ones.
31-
extensions = [
32-
"sphinx.ext.doctest",
33-
"sphinx.ext.todo",
34-
"sphinxcontrib.httpdomain",
35-
]
31+
extensions = ["sphinx.ext.doctest", "sphinx.ext.todo", "sphinxcontrib.httpdomain"]
3632

3733
# Add any paths that contain templates here, relative to this directory.
3834
templates_path = ["_templates"]
@@ -66,7 +62,7 @@
6662
html_theme = "default"
6763

6864
# Output file base name for HTML help builder.
69-
htmlhelp_basename = 'Warehousedoc'
65+
htmlhelp_basename = "Warehousedoc"
7066

7167
# Enable display of todos
7268
todo_include_todos = True

tests/unit/macaroons/test_caveats.py

Lines changed: 80 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,16 @@ def test_verify_valid_predicate(self):
5858
verifier = pretend.stub()
5959
caveat = V1Caveat(verifier)
6060
d = datetime.now() + timedelta(days=1)
61-
tz = pytz.timezone('GMT') # GMT for POC, ideally would be user's local timezone
61+
tz = pytz.timezone("GMT") # GMT for POC, ideally would be user's local timezone
6262
tz_aware = tz.localize(d)
6363
expiration = datetime.strftime(tz_aware, "%Y-%m-%dT%H:%M")
64-
predicate = {"permissions": {"scope": "user", "expiration": expiration}, "version": 1}
64+
predicate = {
65+
"permissions": {"scope": "user", "expiration": expiration},
66+
"version": 1,
67+
}
6568

6669
assert caveat(json.dumps(predicate)) is True
67-
70+
6871
def test_verify_user_invalid_predicate(self):
6972
verifier = pretend.stub()
7073
caveat = V1Caveat(verifier)
@@ -77,8 +80,10 @@ def test_verify_project_invalid_context(self):
7780
verifier = pretend.stub(context=pretend.stub())
7881
caveat = V1Caveat(verifier)
7982

80-
predicate = {"version": 1, "permissions":
81-
{"projects": [{"project-name": "notfoobar"}]}}
83+
predicate = {
84+
"version": 1,
85+
"permissions": {"projects": [{"project-name": "notfoobar"}]},
86+
}
8287
with pytest.raises(InvalidMacaroon):
8388
caveat(json.dumps(predicate))
8489

@@ -87,8 +92,10 @@ def test_verify_project_invalid_project_name(self, db_request):
8792
verifier = pretend.stub(context=project)
8893
caveat = V1Caveat(verifier)
8994

90-
predicate = {"version": 1, "permissions":
91-
{"projects": [{"project-name": "notfoobar"}]}}
95+
predicate = {
96+
"version": 1,
97+
"permissions": {"projects": [{"project-name": "notfoobar"}]},
98+
}
9299
with pytest.raises(InvalidMacaroon):
93100
caveat(json.dumps(predicate))
94101

@@ -110,26 +117,36 @@ def test_verify_project(self, db_request):
110117
verifier = pretend.stub(context=project)
111118
caveat = V1Caveat(verifier)
112119
d = datetime.now() + timedelta(days=1)
113-
tz = pytz.timezone('GMT') # GMT for POC, ideally would be user's local timezone
120+
tz = pytz.timezone("GMT") # GMT for POC, ideally would be user's local timezone
114121
tz_aware = tz.localize(d)
115122
expiration = datetime.strftime(tz_aware, "%Y-%m-%dT%H:%M")
116123

117-
predicate = {"version": 1, "permissions":
118-
{"expiration": expiration, "projects": [{"project-name": "foobar", "version": "1.0"}]}}
124+
predicate = {
125+
"version": 1,
126+
"permissions": {
127+
"expiration": expiration,
128+
"projects": [{"project-name": "foobar", "version": "1.0"}],
129+
},
130+
}
119131
assert caveat(json.dumps(predicate)) is True
120-
132+
121133
def test_verify_releases(self, db_request):
122134
project = ProjectFactory.create(name="foobar")
123135
release = ReleaseFactory.create(project=project)
124136
verifier = pretend.stub(context=project)
125137
caveat = V1Caveat(verifier)
126138
d = datetime.now() + timedelta(days=1)
127-
tz = pytz.timezone('GMT') # GMT for POC, ideally would be user's local timezone
139+
tz = pytz.timezone("GMT") # GMT for POC, ideally would be user's local timezone
128140
tz_aware = tz.localize(d)
129141
expiration = datetime.strftime(tz_aware, "%Y-%m-%dT%H:%M")
130142

131-
predicate = {"version": 1, "permissions":
132-
{"projects": [{"project-name": "foobar", "version": "1.0"}], "expiration": expiration}}
143+
predicate = {
144+
"version": 1,
145+
"permissions": {
146+
"projects": [{"project-name": "foobar", "version": "1.0"}],
147+
"expiration": expiration,
148+
},
149+
}
133150
assert caveat(json.dumps(predicate)) is True
134151

135152
def test_verify_release_exists(self, db_request):
@@ -138,27 +155,38 @@ def test_verify_release_exists(self, db_request):
138155
verifier = pretend.stub(context=project)
139156
caveat = V1Caveat(verifier)
140157
d = datetime.now() + timedelta(days=1)
141-
tz = pytz.timezone('GMT') # GMT for POC, ideally would be user's local timezone
158+
tz = pytz.timezone("GMT") # GMT for POC, ideally would be user's local timezone
142159
tz_aware = tz.localize(d)
143160
expiration = datetime.strftime(tz_aware, "%Y-%m-%dT%H:%M")
144161

145-
predicate = {"version": 1, "permissions":
146-
{"projects": [{"project-name": "foobar", "version": project.latest_version[0]}],
147-
"expiration": expiration}}
162+
predicate = {
163+
"version": 1,
164+
"permissions": {
165+
"projects": [
166+
{"project-name": "foobar", "version": project.latest_version[0]}
167+
],
168+
"expiration": expiration,
169+
},
170+
}
148171
with pytest.raises(InvalidMacaroon):
149172
caveat(json.dumps(predicate))
150-
173+
151174
def test_verify_release_missing(self, db_request):
152175
project = ProjectFactory.create(name="foobar")
153176
verifier = pretend.stub(context=project)
154177
caveat = V1Caveat(verifier)
155178
d = datetime.now() + timedelta(days=1)
156-
tz = pytz.timezone('GMT') # GMT for POC, ideally would be user's local timezone
179+
tz = pytz.timezone("GMT") # GMT for POC, ideally would be user's local timezone
157180
tz_aware = tz.localize(d)
158181
expiration = datetime.strftime(tz_aware, "%Y-%m-%dT%H:%M")
159182

160-
predicate = {"version": 1, "permissions":
161-
{"projects": [{"project-name": "foobar"}], "expiration": expiration}}
183+
predicate = {
184+
"version": 1,
185+
"permissions": {
186+
"projects": [{"project-name": "foobar"}],
187+
"expiration": expiration,
188+
},
189+
}
162190
with pytest.raises(InvalidMacaroon):
163191
caveat(json.dumps(predicate))
164192

@@ -168,24 +196,32 @@ def test_verify_invalid_expiration(self, db_request):
168196
verifier = pretend.stub(context=project)
169197
caveat = V1Caveat(verifier)
170198

171-
predicate = {"version": 1, "permissions":
172-
{"projects": [{"project-name":"foobar", "version": "1.0"}],
173-
"expiration": "notanexpiration"}}
199+
predicate = {
200+
"version": 1,
201+
"permissions": {
202+
"projects": [{"project-name": "foobar", "version": "1.0"}],
203+
"expiration": "notanexpiration",
204+
},
205+
}
174206
with pytest.raises(InvalidMacaroon):
175207
caveat(json.dumps(predicate))
176-
208+
177209
def test_verify_expiration(self, db_request):
178210
project = ProjectFactory.create(name="foobar")
179211
verifier = pretend.stub(context=project)
180212
caveat = V1Caveat(verifier)
181213
d = datetime.now() + timedelta(days=1)
182-
tz = pytz.timezone('GMT') # GMT for POC, ideally would be user's local timezone
214+
tz = pytz.timezone("GMT") # GMT for POC, ideally would be user's local timezone
183215
tz_aware = tz.localize(d)
184216
expiration = datetime.strftime(tz_aware, "%Y-%m-%dT%H:%M")
185217

186-
predicate = {"version": 1, "permissions":
187-
{"projects": [{"project-name": "foobar", "version": "1.0"}],
188-
"expiration": expiration}}
218+
predicate = {
219+
"version": 1,
220+
"permissions": {
221+
"projects": [{"project-name": "foobar", "version": "1.0"}],
222+
"expiration": expiration,
223+
},
224+
}
189225
assert caveat(json.dumps(predicate)) is True
190226

191227
def test_verify_expired(self, db_request):
@@ -194,26 +230,33 @@ def test_verify_expired(self, db_request):
194230
verifier = pretend.stub(context=project)
195231
caveat = V1Caveat(verifier)
196232
d = datetime.now() - timedelta(days=1)
197-
tz = pytz.timezone('GMT') # GMT for POC, ideally would be user's local timezone
233+
tz = pytz.timezone("GMT") # GMT for POC, ideally would be user's local timezone
198234
tz_aware = tz.localize(d)
199235
expiration = datetime.strftime(tz_aware, "%Y-%m-%dT%H:%M")
200236

201-
predicate = {"version": 1, "permissions":
202-
{"projects": [{"project-name": "foobar", "version": "1.0"}],
203-
"expiration": expiration}}
237+
predicate = {
238+
"version": 1,
239+
"permissions": {
240+
"projects": [{"project-name": "foobar", "version": "1.0"}],
241+
"expiration": expiration,
242+
},
243+
}
204244
with pytest.raises(InvalidMacaroon):
205245
caveat(json.dumps(predicate))
206-
246+
207247
def test_verify_expiration_missing(self, db_request):
208248
project = ProjectFactory.create(name="foobar")
209249
verifier = pretend.stub(context=project)
210250
caveat = V1Caveat(verifier)
211251

212-
predicate = {"version": 1, "permissions":
213-
{"projects": [{"project-name": "foobar", "version": "1.0"}]}}
252+
predicate = {
253+
"version": 1,
254+
"permissions": {"projects": [{"project-name": "foobar", "version": "1.0"}]},
255+
}
214256
with pytest.raises(InvalidMacaroon):
215257
caveat(json.dumps(predicate))
216258

259+
217260
class TestVerifier:
218261
def test_creation(self):
219262
macaroon = pretend.stub()

0 commit comments

Comments
 (0)