Skip to content
Snippets Groups Projects
Commit d48c0247 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: update tests to new version

parent 842b18ac
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,8 @@ Person:
responsible:
responsible:
datatype: REFERENCE
revisionOf:
datatype: REFERENCE
results:
datatype: REFERENCE
source:
......
......@@ -90,17 +90,23 @@ class CrawlerTest(unittest.TestCase):
self.assertIsNotNone(ana.get_property("responsible"))
person = db.Record(id=ana.get_property("responsible").value[0])
person.retrieve()
print(person)
self.assertEqual("Only", person.get_property("firstname").value)
# Should have a description
self.assertIsNotNone(ana.description)
# Should reference an experiment
self.assertIsNotNone(ana.get_property("Experiment"))
exp = db.Record(id=ana.get_property("Experiment").value[0])
exp.retrieve()
self.assertEqual("2019-02-03", exp.get_property("date").value)
sources = [get_entity_with_id(el) for el in
ana.get_property("source").value]
count = 0
for s in sources:
if len(s.parents) > 0 and s.parents[0].name == "Experiment":
count += 1
self.assertEqual(count, 1)
self.assertEqual(len(sources), 2)
first_ana = ana
#######################
# # second analysis # #
......@@ -118,10 +124,21 @@ class CrawlerTest(unittest.TestCase):
assert os.path.basename(datfile.path) == "analyse.py"
# Should reference an experiment
self.assertIsNotNone(ana.get_property("Experiment"))
exp = db.Record(id=ana.get_property("Experiment").value[0])
exp.retrieve()
self.assertEqual("2019-02-03", exp.get_property("date").value)
sources = [get_entity_with_id(el) for el in
ana.get_property("source").value]
count = 0
for s in sources:
if len(s.parents) > 0 and s.parents[0].name == "Experiment":
count += 1
self.assertEqual(count, 1)
self.assertEqual(len(sources), 1)
# Should reference the other analysis
self.assertIsNotNone(ana.get_property("revisionOf"))
a = db.Record(id=ana.get_property("revisionOf").value[0])
a.retrieve()
self.assertEqual(a.id, first_ana.id)
def test_simulation(self):
######################
......@@ -162,8 +179,15 @@ class CrawlerTest(unittest.TestCase):
"FIND Simulation with date=2019-02-03 and identifier='something'",
unique=True)
exp = get_entity_with_id(sim.get_property("Experiment").value[0])
self.assertEqual(exp.parents[0].name, "Experiment")
sources = [get_entity_with_id(el) for el in
sim.get_property("source").value]
count = 0
for s in sources:
if len(s.parents) > 0 and s.parents[0].name == "Experiment":
count += 1
self.assertEqual(count, 1)
self.assertEqual(len(sources), 3)
# Should be the same project
assert project_id == sim.get_property("Project").value
......@@ -174,9 +198,9 @@ class CrawlerTest(unittest.TestCase):
# TODO enable revisionOf
# Should have revision
#osim = get_entity_with_id(sim.get_property("revisionOf").value[0])
#self.assertEqual(osim.parents[0].name, "Simulation")
#self.assertNotEqual(osim.id, sim.id)
# osim = get_entity_with_id(sim.get_property("revisionOf").value[0])
# self.assertEqual(osim.parents[0].name, "Simulation")
# self.assertNotEqual(osim.id, sim.id)
# Should have data file
datfile_id = sim.get_property("results").value[0]
......@@ -205,7 +229,7 @@ class CrawlerTest(unittest.TestCase):
assert os.path.basename(datfile.path) == "poster.pdf"
# There should be a file as data attached
datfile_id = pub.get_property("source").value[0]
datfile_id = pub.get_property("source").value[1]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "results.pdf"
......
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