Skip to content

Commit

Permalink
start upload tests #166
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierCladellas committed Dec 17, 2024
1 parent 55ef39e commit 96bc617
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tests/hanlders/testGirderHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class TestGirderHandler:
"""Tests for the GirderHandler class"""
handler = GirderHandler(download_base_dir="./tests/data/outputs")
handler = GirderHandler(download_base_dir="./tests/data/")

def test_initClient(self):
"""Tests girder client initialization"""
Expand Down Expand Up @@ -69,5 +69,31 @@ def test_listChildren(self):
children = self.handler.listChildren(parent_id=test_folder_id, children_name="unkown_children")

def test_upload(self):
"""Tests uploading ressources to girder"""
pass #TODO
"""Tests uploading ressources to girder
- Checks uploading a file
- Checks uploading a folder
- Checks updating a file
- Checks uploading as item
"""
return
test_upload_folder_id = "67615ba54c9ccbdde21a4bf9"
#Uploading a file
with tempfile.NamedTemporaryFile() as tmp:
item_id = self.handler.upload(tmp.name, parent_id=test_upload_folder_id,return_id=True)

assert item_id

with tempfile.TemporaryDirectory() as tmpdir:
with tempfile.NamedTemporaryFile(dir=tmpdir) as tmp1, tempfile.NamedTemporaryFile(dir=tmpdir) as tmp2:
item_id = self.handler.upload(tmpdir, parent_id=test_upload_folder_id,return_id=True)

assert item_id

with tempfile.NamedTemporaryFile() as tmp:
item_id1 = self.handler.upload(tmp.name, parent_id=test_upload_folder_id,return_id=True)
assert item_id1
with open(tmp.name,"w") as f:
f.write("OVERWRITE CONTENT")
item_id2 = self.handler.upload(tmp.name, parent_id=test_upload_folder_id,return_id=True)
assert item_id2 == item_id1

0 comments on commit 96bc617

Please sign in to comment.