Skip to content

Commit f913f6b

Browse files
committed
fix black formating error
Signed-off-by: ziadhany <ziadhany2016@gmail.com>
1 parent e425f46 commit f913f6b

2 files changed

Lines changed: 39 additions & 52 deletions

File tree

‎tests/end_to_end/base.py‎

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ def _start_opensearch_container(cls):
189189
# Keep the security plugin disabled so the server is reachable
190190
# through plain HTTP without authentication.
191191
cls.opensearch_container = (
192-
OpenSearchContainer(image=OPENSEARCH_IMAGE)
193-
.with_exposed_ports(9200)
194-
.with_env("DISABLE_SECURITY_PLUGIN", "true")
192+
OpenSearchContainer(image=OPENSEARCH_IMAGE).with_exposed_ports(9200).with_env("DISABLE_SECURITY_PLUGIN", "true")
195193
)
196194
cls.opensearch_container.start()
197195
wait_for_logs(cls.opensearch_container, ".*recovered .* indices into cluster_state.*")
@@ -269,15 +267,11 @@ def _start_grimoirelab(cls):
269267
text=True,
270268
)
271269
if proc.returncode != 0:
272-
raise RuntimeError(
273-
f"Error running 'grimoirelab admin create-user'. stdout: {proc.stdout}. stderr: {proc.stderr}"
274-
)
270+
raise RuntimeError(f"Error running 'grimoirelab admin create-user'. stdout: {proc.stdout}. stderr: {proc.stderr}")
275271

276272
cls._promote_admin_superuser()
277273

278-
cls.grimoirelab_server = cls._start_grimoirelab_process(
279-
"server", ["grimoirelab", "run", "server", "--dev"]
280-
)
274+
cls.grimoirelab_server = cls._start_grimoirelab_process("server", ["grimoirelab", "run", "server", "--dev"])
281275
cls._wait_for_grimoirelab_server()
282276

283277
cls.grimoirelab_eventizers = cls._start_grimoirelab_process(
@@ -288,9 +282,7 @@ def _start_grimoirelab(cls):
288282
)
289283
# docker-compose also runs the ushers, which dispatch the
290284
# scheduled tasks; run them too.
291-
cls.grimoirelab_ushers = cls._start_grimoirelab_process(
292-
"ushers", ["grimoirelab", "run", "ushers"]
293-
)
285+
cls.grimoirelab_ushers = cls._start_grimoirelab_process("ushers", ["grimoirelab", "run", "ushers"])
294286

295287
# Fail fast (with logs) if any worker crashes on startup, instead
296288
# of failing later with an obscure timeout.
@@ -300,8 +292,7 @@ def _start_grimoirelab(cls):
300292
time.sleep(3)
301293
if cls.grimoirelab_ushers.poll() is not None:
302294
logging.warning(
303-
"'grimoirelab run ushers' exited unexpectedly; continuing without it.\n"
304-
+ cls._dump_grimoirelab_logs()
295+
"'grimoirelab run ushers' exited unexpectedly; continuing without it.\n" + cls._dump_grimoirelab_logs()
305296
)
306297

307298
@staticmethod
@@ -319,9 +310,7 @@ def _promote_admin_superuser():
319310
)
320311
proc = subprocess.run([sys.executable, "-c", code], capture_output=True, text=True)
321312
if proc.returncode != 0:
322-
raise RuntimeError(
323-
f"Error promoting '{GRIMOIRELAB_USER}' to superuser. stdout: {proc.stdout}. stderr: {proc.stderr}"
324-
)
313+
raise RuntimeError(f"Error promoting '{GRIMOIRELAB_USER}' to superuser. stdout: {proc.stdout}. stderr: {proc.stderr}")
325314

326315
@classmethod
327316
def _wait_for_grimoirelab_server(cls, timeout=GRIMOIRELAB_SERVER_TIMEOUT):
@@ -342,9 +331,7 @@ def _wait_for_grimoirelab_server(cls, timeout=GRIMOIRELAB_SERVER_TIMEOUT):
342331
except Exception:
343332
time.sleep(1)
344333

345-
raise RuntimeError(
346-
f"GrimoireLab server was not ready after {timeout} seconds.\n" + cls._dump_grimoirelab_logs()
347-
)
334+
raise RuntimeError(f"GrimoireLab server was not ready after {timeout} seconds.\n" + cls._dump_grimoirelab_logs())
348335

349336
@classmethod
350337
def _confirm_server_is_ours(cls):
@@ -376,9 +363,7 @@ def _wait_for_worker_logs(cls, name, proc, timeout=GRIMOIRELAB_WORKERS_TIMEOUT):
376363

377364
while time.time() - start < timeout:
378365
if proc.poll() is not None:
379-
raise RuntimeError(
380-
f"GrimoireLab '{name}' process exited unexpectedly.\n" + cls._dump_grimoirelab_logs()
381-
)
366+
raise RuntimeError(f"GrimoireLab '{name}' process exited unexpectedly.\n" + cls._dump_grimoirelab_logs())
382367
try:
383368
with open(log_path, errors="replace") as f:
384369
if "*** Listening on" in f.read():
@@ -430,16 +415,13 @@ def _api_headers(cls, api_url):
430415
timeout=30,
431416
)
432417
except requests.RequestException as exc:
433-
raise RuntimeError(
434-
f"Error connecting to the GrimoireLab server: {exc!r}\n\n" + cls._server_diagnostics()
435-
)
418+
raise RuntimeError(f"Error connecting to the GrimoireLab server: {exc!r}\n\n" + cls._server_diagnostics())
436419

437420
if response.status_code != 200:
438421
raise RuntimeError(
439422
"Error getting the API token. "
440423
f"Status: {response.status_code}. "
441-
f"Detail: {cls._html_error_detail(response.text)}\n\n"
442-
+ cls._server_diagnostics()
424+
f"Detail: {cls._html_error_detail(response.text)}\n\n" + cls._server_diagnostics()
443425
)
444426

445427
data = response.json()
@@ -504,16 +486,14 @@ def _api_get_or_create(cls, headers, get_url, post_url, body, kind):
504486
if response.status_code != 404:
505487
raise RuntimeError(
506488
f"Error checking the {kind}. Status: {response.status_code}. "
507-
f"Detail: {cls._html_error_detail(response.text)}\n\n"
508-
+ cls._server_diagnostics()
489+
f"Detail: {cls._html_error_detail(response.text)}\n\n" + cls._server_diagnostics()
509490
)
510491

511492
response = requests.post(post_url, headers=headers, json=body, timeout=30)
512493
if response.status_code not in (200, 201):
513494
raise RuntimeError(
514495
f"Error creating the {kind}. Status: {response.status_code}. "
515-
f"Detail: {cls._html_error_detail(response.text)}\n\n"
516-
+ cls._server_diagnostics()
496+
f"Detail: {cls._html_error_detail(response.text)}\n\n" + cls._server_diagnostics()
517497
)
518498

519499
@classmethod
@@ -523,16 +503,26 @@ def _preload_repositories(cls):
523503
grimoirelab_metrics,
524504
[
525505
ARCHIVED_REPOS_FILE,
526-
"--grimoirelab-url", GRIMOIRELAB_URL,
527-
"--grimoirelab-user", GRIMOIRELAB_USER,
528-
"--grimoirelab-password", GRIMOIRELAB_PASSWORD,
529-
"--grimoirelab-ecosystem", GRIMOIRELAB_ECOSYSTEM,
530-
"--grimoirelab-project", GRIMOIRELAB_PROJECT,
531-
"--opensearch-url", cls.opensearch_url,
532-
"--opensearch-user", cls.opensearch_user,
533-
"--opensearch-password", cls.opensearch_password,
534-
"--opensearch-index", OPENSEARCH_INDEX,
535-
"--output", cls.temp_file.name,
506+
"--grimoirelab-url",
507+
GRIMOIRELAB_URL,
508+
"--grimoirelab-user",
509+
GRIMOIRELAB_USER,
510+
"--grimoirelab-password",
511+
GRIMOIRELAB_PASSWORD,
512+
"--grimoirelab-ecosystem",
513+
GRIMOIRELAB_ECOSYSTEM,
514+
"--grimoirelab-project",
515+
GRIMOIRELAB_PROJECT,
516+
"--opensearch-url",
517+
cls.opensearch_url,
518+
"--opensearch-user",
519+
cls.opensearch_user,
520+
"--opensearch-password",
521+
cls.opensearch_password,
522+
"--opensearch-index",
523+
OPENSEARCH_INDEX,
524+
"--output",
525+
cls.temp_file.name,
536526
"--from-date=2000-01-01",
537527
],
538528
)

‎tests/end_to_end/test_cli.py‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@
3535
FROM_DATE = datetime.datetime(2000, 1, 1)
3636

3737
ERROR_GRIMOIRELAB_URL = "http://localhost:8001"
38-
REPOSITORIES_URL = (
39-
f"{GRIMOIRELAB_URL}/api/v1/ecosystems/{GRIMOIRELAB_ECOSYSTEM}"
40-
f"/projects/{GRIMOIRELAB_PROJECT}/repos/"
41-
)
38+
REPOSITORIES_URL = f"{GRIMOIRELAB_URL}/api/v1/ecosystems/{GRIMOIRELAB_ECOSYSTEM}" f"/projects/{GRIMOIRELAB_PROJECT}/repos/"
4239
ERROR_REPOSITORIES_URL = (
43-
f"{ERROR_GRIMOIRELAB_URL}/api/v1/ecosystems/{GRIMOIRELAB_ECOSYSTEM}"
44-
f"/projects/{GRIMOIRELAB_PROJECT}/repos/"
40+
f"{ERROR_GRIMOIRELAB_URL}/api/v1/ecosystems/{GRIMOIRELAB_ECOSYSTEM}" f"/projects/{GRIMOIRELAB_PROJECT}/repos/"
4541
)
4642

4743

@@ -132,7 +128,10 @@ def test_metrics(self):
132128
)
133129

134130
package = metrics["packages"]["package0"]
135-
self.assertEqual(package["repository"], "https://github.com/angular/quickstart.git", )
131+
self.assertEqual(
132+
package["repository"],
133+
"https://github.com/angular/quickstart.git",
134+
)
136135
package_metrics = package["metrics"]
137136
self.assertEqual(package_metrics["active_branches"], 0)
138137
self.assertEqual(package_metrics["casual_regular_contributors_rate"], 0.0)
@@ -171,9 +170,7 @@ def test_metrics(self):
171170
self.assertIsNone(package_metadata["first_commit_date"])
172171
self.assertIsNone(package_metadata["last_commit"])
173172
self.assertIsNone(package_metadata["last_commit_date"])
174-
self.assertEqual(package["score"]["metadata"],
175-
{"ecosystem": "npm", "model": "health", "version": "0.2"}
176-
)
173+
self.assertEqual(package["score"]["metadata"], {"ecosystem": "npm", "model": "health", "version": "0.2"})
177174
self.assertEqual(package["score"]["value"], 1.0)
178175

179176

0 commit comments

Comments
 (0)