Skip to content

Commit

Permalink
Clean up db backups after tests to prevent issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Jun 27, 2024
1 parent 4e124cc commit 6a50ac2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kolibri/core/deviceadmin/tests/test_dbrestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ def test_fail_on_unknown_file():
get_dtm_from_backup_name("this-file-has-no-time")


def _clear_backups(folder):
for f in os.listdir(folder):
os.remove(os.path.join(folder, f))


@pytest.mark.django_db
@pytest.mark.filterwarnings("ignore:Overriding setting DATABASES")
def test_restore_from_latest():
Expand Down Expand Up @@ -146,6 +151,7 @@ def test_restore_from_latest():
assert (
Facility.objects.filter(name="test latest", kind=FACILITY).count() == 1
)
_clear_backups(default_backup_folder())


@pytest.mark.django_db
Expand Down Expand Up @@ -176,6 +182,7 @@ def test_restore_from_file_to_memory():
call_command("dbrestore", backup)
# Test that the user has been restored!
assert Facility.objects.filter(name="test file", kind=FACILITY).count() == 1
_clear_backups(dest_folder)


@pytest.mark.django_db
Expand Down Expand Up @@ -212,6 +219,7 @@ def test_restore_from_file_to_file():
call_command("dbrestore", backup)
# Test that the user has been restored!
assert Facility.objects.filter(name="test file", kind=FACILITY).count() == 1
_clear_backups(dest_folder)


def test_search_latest():
Expand Down

0 comments on commit 6a50ac2

Please sign in to comment.