Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
TraciebelWairimu authored and Wambere committed Feb 29, 2024
1 parent 2cd94c9 commit 9075ede
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions importer/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import csv
import json
import uuid
Expand Down Expand Up @@ -876,9 +877,13 @@ def clean_duplicates(users, cascade_delete):
# Create a csv file and initialize the CSV writer
def write_csv(data, resource_type, fieldnames):
logging.info("Writing to csv file")
path = 'csv/exports'
if not os.path.exists(path):
os.makedirs(path)

current_time = datetime.now().strftime("%Y-%m-%d-%H-%M")
csv_file = f"csv/exports/{current_time}-export_{resource_type}.csv"
with open(csv_file, "w", newline="") as file:
csv_file = f"{path}/{current_time}-export_{resource_type}.csv"
with open(csv_file, 'w', newline='') as file:
csv_writer = csv.writer(file)
csv_writer.writerow(fieldnames)
csv_writer.writerows(data)
Expand Down
4 changes: 3 additions & 1 deletion importer/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,11 @@ def test_export_resource_to_csv(
[
"City1",
"active",
"update",
"ba787982-b973-4bd5-854e-eacbe161e297",
"ba787 982-b973-4bd5-854e-eacbe161e297",
"test location-1",
"Location/18fcbc2e-4240-4a84-a270-7a444523d7b6",
"18fcbc2e-4240-4a84-a270-7a444523d7b6",
"Jurisdiction",
"jdn",
"Jurisdiction",
Expand All @@ -475,6 +476,7 @@ def test_export_resource_to_csv(
test_elements = [
"name",
"status",
"method",
"id",
"identifier",
"parentName",
Expand Down

0 comments on commit 9075ede

Please sign in to comment.