tests: reformat tests using black.
This commit is contained in:
parent
42263d05f9
commit
5005ca346b
1 changed files with 161 additions and 140 deletions
|
|
@ -60,7 +60,7 @@ class FakeFile:
|
|||
The file should be deleted after use. If not, it will be deleted at the end of
|
||||
session with the whole temporary test files directory.
|
||||
"""
|
||||
name = ''.join(random.choices(self.ALPHABET, k=8))
|
||||
name = "".join(random.choices(self.ALPHABET, k=8))
|
||||
return self.dest_files / name
|
||||
|
||||
def size(self, size: int, use_cache: bool = True):
|
||||
|
|
@ -72,7 +72,7 @@ class FakeFile:
|
|||
if not use_cache or not dest_path.exists():
|
||||
hash_ = hashlib.sha256()
|
||||
remaining = size
|
||||
with dest_path.open('wb') as f:
|
||||
with dest_path.open("wb") as f:
|
||||
while remaining:
|
||||
if remaining > self.BUF_SIZE:
|
||||
to_get = self.BUF_SIZE
|
||||
|
|
@ -92,7 +92,7 @@ class FakeFile:
|
|||
def get_dest_hash(self, dest_file: Path) -> str:
|
||||
"""Calculate hash of file at given path"""
|
||||
hash_ = hashlib.sha256()
|
||||
with dest_file.open('rb') as f:
|
||||
with dest_file.open("rb") as f:
|
||||
while True:
|
||||
buf = f.read(self.BUF_SIZE)
|
||||
if not buf:
|
||||
|
|
@ -105,15 +105,15 @@ class TestMessage(EmailMessage):
|
|||
|
||||
@property
|
||||
def subject(self):
|
||||
return self['subject']
|
||||
return self["subject"]
|
||||
|
||||
@property
|
||||
def from_(self):
|
||||
return self['from']
|
||||
return self["from"]
|
||||
|
||||
@property
|
||||
def to(self):
|
||||
return self['to']
|
||||
return self["to"]
|
||||
|
||||
@property
|
||||
def body(self):
|
||||
|
|
@ -150,10 +150,10 @@ def test_profiles():
|
|||
2: 1,
|
||||
3: 1,
|
||||
}
|
||||
for server_idx in range(1, nb_servers+1):
|
||||
for server_idx in range(1, nb_servers + 1):
|
||||
account_stop = accounts_by_servers[server_idx] + 1
|
||||
for account_idx in range(1, account_stop):
|
||||
profile_suff = f"_s{server_idx}" if server_idx>1 else ""
|
||||
profile_suff = f"_s{server_idx}" if server_idx > 1 else ""
|
||||
profile = f"account{account_idx}{profile_suff}"
|
||||
profiles.append(profile)
|
||||
try:
|
||||
|
|
@ -161,7 +161,7 @@ def test_profiles():
|
|||
f"account{account_idx}@server{server_idx}.test",
|
||||
"test",
|
||||
profile=profile,
|
||||
host=f"server{server_idx}.test"
|
||||
host=f"server{server_idx}.test",
|
||||
)
|
||||
except sh.ErrorReturnCode_19:
|
||||
# this is the conlict exit code, this can happen when tests are run
|
||||
|
|
@ -186,25 +186,20 @@ def pubsub_nodes(test_profiles):
|
|||
One node will be on account1's PEP, the other one on pubsub.server1.test.
|
||||
"""
|
||||
li.pubsub.node.create(
|
||||
"-f", "access_model", "open",
|
||||
node="test",
|
||||
profile="account1", connect=True
|
||||
"-f", "access_model", "open", node="test", profile="account1", connect=True
|
||||
)
|
||||
li.pubsub.node.create(
|
||||
"-f", "access_model", "open",
|
||||
service="pubsub.server1.test", node="test",
|
||||
profile="account1"
|
||||
"-f",
|
||||
"access_model",
|
||||
"open",
|
||||
service="pubsub.server1.test",
|
||||
node="test",
|
||||
profile="account1",
|
||||
)
|
||||
yield
|
||||
li.pubsub.node.delete(node="test", profile="account1", connect=True, force=True)
|
||||
li.pubsub.node.delete(
|
||||
node="test",
|
||||
profile="account1", connect=True,
|
||||
force=True
|
||||
)
|
||||
li.pubsub.node.delete(
|
||||
service="pubsub.server1.test", node="test",
|
||||
profile="account1",
|
||||
force=True
|
||||
service="pubsub.server1.test", node="test", profile="account1", force=True
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue