Skip to content

Commit

Permalink
Issue #137: rename metadata.buil_picture_set & update ref (tests pass…
Browse files Browse the repository at this point in the history
…ing)
  • Loading branch information
Francois-Werbrouck committed Oct 22, 2024
1 parent 702f07a commit 96c862b
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions datastore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async def new_user(cursor, email, connection_string, tier="user") -> User:
raise ContainerCreationError("Error creating the user container: container does not exists")

# Link the container to the user in the database
pic_set_metadata = data_picture_set.build_picture_set(
pic_set_metadata = data_picture_set.build_picture_set_metadata(
user_id=user_uuid, nb_picture=0
)
pic_set_id = picture.new_picture_set(
Expand Down Expand Up @@ -154,7 +154,7 @@ async def create_picture_set(
f"User not found based on the given id: {user_id}"
)

picture_set_metadata = data_picture_set.build_picture_set(user_id, nb_pictures)
picture_set_metadata = data_picture_set.build_picture_set_metadata(user_id, nb_pictures)
picture_set_id = picture.new_picture_set(
cursor=cursor,
picture_set=picture_set_metadata,
Expand Down Expand Up @@ -335,7 +335,7 @@ async def upload_pictures(
f"User not found based on the given id: {user_id}"
)

empty_picture = data_picture_set.build_picture_set(
empty_picture = data_picture_set.build_picture_set_metadata(
user_id, len(hashed_pictures)
)

Expand Down
2 changes: 1 addition & 1 deletion datastore/bin/upload_picture_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def upload_picture_set(
f"User not found based on the given id: {user_id}"
)

picture_set = picture_set_metadata.build_picture_set(user_id, len(pictures))
picture_set = picture_set_metadata.build_picture_set_metadata(user_id, len(pictures))
picture_set_id = picture_query.new_picture_set(
cursor=cursor, picture_set=picture_set, user_id=user_id
)
Expand Down
4 changes: 2 additions & 2 deletions datastore/db/metadata/picture_set/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class PictureSetCreationError(Exception):
pass


def build_picture_set(user_id: str, nb_picture: int):
def build_picture_set_metadata(user_id: str, nb_picture: int):
"""
This function builds the picture_set needed to represent each folder (with pictures in it) of a container.
This function builds the picture_set_metadata needed to represent each folder (with pictures in it) of a container.
Parameters:
- user_id (str): The UUID of the user uploading.
Expand Down
2 changes: 1 addition & 1 deletion nachet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ async def delete_picture_set_with_archive(
if not await azure_storage.is_a_folder(dev_container_client, str(user_id)):
await azure_storage.create_folder(dev_container_client, str(user_id))

picture_set = data_picture_set.build_picture_set(
picture_set = data_picture_set.build_picture_set_metadata(
dev_user_id, len(validated_pictures)
)
dev_picture_set_id = picture.new_picture_set(
Expand Down
2 changes: 1 addition & 1 deletion nachet/bin/deployment_mass_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def local_import(
]
)
# build picture_set
picture_set = picture_set_metadata.build_picture_set(
picture_set = picture_set_metadata.build_picture_set_metadata(
user_id=user_id, nb_picture=nb_file
)

Expand Down
2 changes: 1 addition & 1 deletion tests/fertiscan/db/test_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def setUp(self):
self.user_email = "testessr@email"
self.user_id = user.register_user(self.cursor, self.user_email)
self.folder_name = "test-folder"
self.picture_set = picture_set.build_picture_set(self.user_id, 1)
self.picture_set = picture_set.build_picture_set_metadata(self.user_id, 1)
self.picture_set_id = picture.new_picture_set(
self.cursor, self.picture_set, self.user_id, self.folder_name
)
Expand Down
2 changes: 1 addition & 1 deletion tests/nachet/db/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def setUp(self):
self.pic_encoded = base64.b64encode(self.image_byte_array.getvalue()).decode(
"utf8"
)
self.picture_set = picture_set_data.build_picture_set(self.user_id, 1)
self.picture_set = picture_set_data.build_picture_set_metadata(self.user_id, 1)
self.nb_seed = 1
self.picture = picture_data.build_picture(
self.pic_encoded, "www.link.com", self.nb_seed, 1.0, ""
Expand Down
2 changes: 1 addition & 1 deletion tests/nachet/db/test_picture.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def setUp(self):
"utf8"
)
self.nb_seed = 1
self.picture_set = picture_set_data.build_picture_set(self.user_id, 1)
self.picture_set = picture_set_data.build_picture_set_metadata(self.user_id, 1)
self.picture = picture_data.build_picture(
self.pic_encoded, "www.link.com", self.nb_seed, 1.0, ""
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def setUp(self):
"utf8"
)
self.nb_seed = 1
self.picture_set = picture_set_data.build_picture_set(self.user_id, 1)
self.picture_set = picture_set_data.build_picture_set_metadata(self.user_id, 1)
self.picture = picture_data.build_picture(
self.pic_encoded, "www.link.com", self.nb_seed, 1.0, ""
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_build_picture_set(self):
"""
This test checks if the build_picture_set function returns a valid JSON object
"""
picture_set = picture_set_data.build_picture_set(self.user_id, self.nb_pictures)
picture_set = picture_set_data.build_picture_set_metadata(self.user_id, self.nb_pictures)
data = json.loads(picture_set)
self.assertEqual(data["image_data_picture_set"]["number_of_images"], 1)
self.assertEqual(data["audit_trail"]["upload_date"], str(date.today()))
Expand Down

0 comments on commit 96c862b

Please sign in to comment.