Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhwaniartefact committed Sep 28, 2023
1 parent 1c64d31 commit d9872c3
Showing 1 changed file with 59 additions and 53 deletions.
112 changes: 59 additions & 53 deletions src/dashboard/tests/test_filesystem_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ def setUp(self):
self.client.login(username="test", password="test")
helpers.set_setting("dashboard_uuid", "test-uuid")

def test_fixtures(self):
objs = models.SIPArrange.objects.all()
assert len(objs) > 0

def test_arrange_contents_data_no_path(self):
# Call endpoint
response = self.client.get(
Expand Down Expand Up @@ -230,55 +226,6 @@ def test_move_within_arrange(self):
assert b64encode_string("newsip") in response_dict["entries"]
assert len(response_dict["entries"]) == 2

@mock.patch(
"storageService.get_first_location",
return_value={"uuid": "355d110f-b641-4b6b-b1c0-8426e63951e5"},
)
@mock.patch(
"storageService.get_file_metadata",
side_effect=[
[
{
"fileuuid": "0b603cee-1f8a-4842-996a-e02a0307ccf7",
"sipuuid": "99c87143-6f74-4398-84e0-14a8ca4bd05a",
}
],
[
{
"fileuuid": "03a33ef5-8714-46cc-aefe-7283186341ca",
"sipuuid": "4ae7b624-9ba7-452a-adbc-1588223b7098",
}
],
],
)
@mock.patch(
"storageService.browse_location",
return_value={
"directories": [],
"entries": ["error.txt", "tree_a.txt"],
"properties": {
"error.txt": {"size": 8},
"tree_a.txt": {"size": 6},
},
},
)
def test_copy_within_arrange(
self, browse_location, get_file_metadata, get_first_location
):
# Copy directory
response = self.client.post(
reverse("filesystem_ajax:copy_to_arrange"),
data={
"filepath": b64encode_string("/originals/objects/"),
"destination": b64encode_string("/arrange/"),
},
follow=True,
)
assert response.status_code == 201
assert json.loads(response.content.decode("utf8")) == {
"message": "Files added to the SIP."
}

def test_copy_from_arrange_to_completed(self):
sip_uuid = "a29e7e86-eca9-43b6-b059-6f23a9802dc8"
models.SIP.objects.create(uuid=sip_uuid)
Expand Down Expand Up @@ -670,3 +617,62 @@ def test_contents_sorting(db, tmp_path, admin_client):
b64encode_string("a"),
b64encode_string("e"),
]


@pytest.mark.django_db
@mock.patch(
"storageService.get_first_location",
return_value={"uuid": "355d110f-b641-4b6b-b1c0-8426e63951e5"},
)
@mock.patch(
"storageService.get_file_metadata",
side_effect=[
[
{
"fileuuid": "0b603cee-1f8a-4842-996a-e02a0307ccf7",
"sipuuid": "99c87143-6f74-4398-84e0-14a8ca4bd05a",
}
],
[
{
"fileuuid": "03a33ef5-8714-46cc-aefe-7283186341ca",
"sipuuid": "4ae7b624-9ba7-452a-adbc-1588223b7098",
}
],
],
)
@mock.patch(
"storageService.browse_location",
return_value={
"directories": [],
"entries": ["error.txt", "tree_a.txt"],
"properties": {
"error.txt": {"size": 8},
"tree_a.txt": {"size": 6},
},
},
)
def test_copy_within_arrange(
browse_location, get_file_metadata, get_first_location, admin_client
):
helpers.set_setting("dashboard_uuid", "test-uuid")

# Verify there is no SipArrange
assert models.SIPArrange.objects.count() == 0

# Copy directory
response = admin_client.post(
reverse("filesystem_ajax:copy_to_arrange"),
data={
"filepath": b64encode_string("/originals/objects/"),
"destination": b64encode_string("/arrange/"),
},
follow=True,
)
assert response.status_code == 201
assert json.loads(response.content.decode("utf8")) == {
"message": "Files added to the SIP."
}

# Verify SIPArrange are created as expected
assert models.SIPArrange.objects.count() == 2

0 comments on commit d9872c3

Please sign in to comment.