Skip to content
Snippets Groups Projects
Commit 762a3b81 authored by Jedrzej Rybicki's avatar Jedrzej Rybicki
Browse files

tuples insead of dicts

parent c2d0ef52
No related branches found
No related tags found
No related merge requests found
......@@ -65,7 +65,7 @@ class JsonFileStorageAdapter(AbstractLocationDataStorageAdapter):
if not os.path.isfile(p):
continue
data = self.__load_object(p)
retList.append({data.actualData.name: f})
retList.append((data.actualData.name, f))
return retList
def add_new(self, n_type: LocationDataType, data: LocationData, user_name: str):
......@@ -94,6 +94,7 @@ class JsonFileStorageAdapter(AbstractLocationDataStorageAdapter):
def delete(self, n_type: LocationDataType, oid: str, usr: str):
fullpath = self.__get_object_path(value=n_type.value, oid=oid)
print(f"Removing {fullpath}")
os.remove(fullpath)
def get_owner(self, type: LocationDataType, oid: str):
......
......@@ -18,6 +18,7 @@ class UserTests(TestCase):
def tearDown(self):
apiserver.app.dependency_overrides={}
def test_me(self):
......@@ -44,4 +45,25 @@ class UserTests(TestCase):
self.assertIsNotNone(oid)
self.assertEqual(dty, my_data)
self.client.delete(f'/dataset/{oid}')
self.client.delete(f"/dataset/{oid}")
def test_create_and_get(self):
dss = [{'name': f"ds_{i}", 'url': f"http://www.o.com/{i}"} for i in range(5)]
for d in dss:
rsp = self.client.post('/dataset', json=d)
self.assertEqual(rsp.status_code, 200)
(oid, dty) = rsp.json()
d['id'] = oid
for d in dss:
i = d['id']
rsp = self.client.get(f"/dataset/{i}")
self.assertEqual(rsp.status_code, 200)
dty = rsp.json()
self.assertEqual(d['name'], dty['name'])
self.assertEqual(d['url'], dty['url'])
self.client.delete(f"/dataset/{i}")
......@@ -48,9 +48,9 @@ class SomeTests(unittest.TestCase):
lst = self.store.get_list(n_type=LocationDataType.DATASET)
self.assertEqual(len(lst), 1, 'One should be there')
m_o = lst[0]
self.assertEqual(list(m_o.keys())[0], l_data.name)
self.assertEqual(list(m_o.values())[0], oid)
(n_name, n_o) = lst[0]
self.assertEqual(n_name, l_data.name)
self.assertEqual(n_o, oid)
def test_get_details(self):
# get_details(self, n_type: LocationDataType, oid: str):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment