Skip to content

Commit

Permalink
chore: Fix client tests not working without web app docker container (#…
Browse files Browse the repository at this point in the history
…855)

* Ignore "No such container" error

* Remove "sudo" from docker commands
  • Loading branch information
RisingOrange authored Dec 30, 2023
1 parent 2ace8f7 commit ad16933
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tests/client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def client_with_server_setup(vcr: VCR, marks: List[str], request: FixtureRequest
# Restore DB from dump
result = subprocess.run(
[
"sudo",
"docker",
"exec",
"-i",
Expand Down Expand Up @@ -152,7 +151,6 @@ def create_db_dump_if_not_exists() -> None:
# Check if DB dump exists
result = subprocess.run(
[
"sudo",
"docker",
"exec",
"-i",
Expand All @@ -178,7 +176,6 @@ def create_db_dump_if_not_exists() -> None:
# Prepare the DB state
result = subprocess.run(
[
"sudo",
"docker",
"exec",
DJANGO_CONTAINER_NAME,
Expand All @@ -199,7 +196,6 @@ def create_db_dump_if_not_exists() -> None:
# Dump the DB to a file to be able to restore it before each test
result = subprocess.run(
[
"sudo",
"docker",
"exec",
DB_CONTAINER_NAME,
Expand All @@ -223,7 +219,6 @@ def remove_db_dump() -> Generator:
"""Remove the db dump on the start of the session so that it is re-created for each session."""
result = subprocess.run(
[
"sudo",
"docker",
"exec",
DB_CONTAINER_NAME,
Expand All @@ -238,6 +233,9 @@ def remove_db_dump() -> Generator:
if result.returncode == 0 or NO_SUCH_FILE_OR_DIRECTORY_MESSAGE in result.stderr:
# Nothing to do
pass
elif result.returncode == 1 and "No such container" in result.stderr:
# Nothing to do
pass
elif "Container" in result.stderr and "is not running" in result.stderr:
# Container is not running, nothing to do
pass
Expand Down

0 comments on commit ad16933

Please sign in to comment.