mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-22 02:36:02 +02:00
fixed paths on export and import scripts
This commit is contained in:
parent
41bfa3991d
commit
08b0b592b2
3 changed files with 5 additions and 5 deletions
|
@ -49,11 +49,11 @@ class Command(BaseCommand):
|
||||||
matching_files = [file for file in os.listdir(tmp_dir) if file.startswith(pattern)]
|
matching_files = [file for file in os.listdir(tmp_dir) if file.startswith(pattern)]
|
||||||
for file_path in matching_files:
|
for file_path in matching_files:
|
||||||
# Add each file to the zip archive
|
# Add each file to the zip archive
|
||||||
zipf.write(file_path, os.path.basename(file_path))
|
zipf.write(f"tmp/{file_path}", os.path.basename(file_path))
|
||||||
logger.info(f"Added {file_path} to {zip_file_path}")
|
logger.info(f"Added {file_path} to {zip_file_path}")
|
||||||
|
|
||||||
# Remove the file after adding to zip
|
# Remove the file after adding to zip
|
||||||
os.remove(file_path)
|
os.remove(f"tmp/{file_path}")
|
||||||
logger.info(f"Removed {file_path}")
|
logger.info(f"Removed {file_path}")
|
||||||
|
|
||||||
def export_table(self, table_name):
|
def export_table(self, table_name):
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Command(BaseCommand):
|
||||||
matching_files = [file for file in os.listdir(tmp_dir) if file.startswith(pattern)]
|
matching_files = [file for file in os.listdir(tmp_dir) if file.startswith(pattern)]
|
||||||
for csv_filename in matching_files:
|
for csv_filename in matching_files:
|
||||||
try:
|
try:
|
||||||
with open(csv_filename, "r") as csvfile:
|
with open(f"tmp/{csv_filename}", "r") as csvfile:
|
||||||
dataset = tablib.Dataset().load(csvfile.read(), format="csv")
|
dataset = tablib.Dataset().load(csvfile.read(), format="csv")
|
||||||
result = resource_instance.import_data(dataset, dry_run=False, skip_epp_save=self.skip_epp_save)
|
result = resource_instance.import_data(dataset, dry_run=False, skip_epp_save=self.skip_epp_save)
|
||||||
if result.has_errors():
|
if result.has_errors():
|
||||||
|
|
|
@ -934,13 +934,13 @@ class TestExportTables(MockEppLib):
|
||||||
# Check that the CSV file was written
|
# Check that the CSV file was written
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
# Check that os.remove was called
|
# Check that os.remove was called
|
||||||
mock_remove.assert_any_call(f"{table_name}_1.csv")
|
mock_remove.assert_any_call(f"tmp/{table_name}_1.csv")
|
||||||
|
|
||||||
# Check that the zipfile was created and files were added
|
# Check that the zipfile was created and files were added
|
||||||
mock_zipfile.assert_called_once_with("tmp/exported_tables.zip", "w", compression=pyzipper.ZIP_DEFLATED)
|
mock_zipfile.assert_called_once_with("tmp/exported_tables.zip", "w", compression=pyzipper.ZIP_DEFLATED)
|
||||||
zipfile_instance = mock_zipfile.return_value.__enter__.return_value
|
zipfile_instance = mock_zipfile.return_value.__enter__.return_value
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
zipfile_instance.write.assert_any_call(f"{table_name}_1.csv", f"{table_name}_1.csv")
|
zipfile_instance.write.assert_any_call(f"tmp/{table_name}_1.csv", f"{table_name}_1.csv")
|
||||||
|
|
||||||
# Verify logging for added files
|
# Verify logging for added files
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue