diff tests/e2e/conftest.py @ 4305:4cd4922de876

tests: reformat tests using black.
author Goffi <goffi@goffi.org>
date Thu, 26 Sep 2024 16:11:56 +0200
parents d78b5eae912a
children
line wrap: on
line diff
--- a/tests/e2e/conftest.py	Fri Sep 06 18:07:44 2024 +0200
+++ b/tests/e2e/conftest.py	Thu Sep 26 16:11:56 2024 +0200
@@ -60,7 +60,7 @@
         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 @@
         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 @@
     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 @@
 
     @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 @@
         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 @@
                     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 @@
     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
     )