diff --git a/integrationtests/full_test/model.yml b/integrationtests/full_test/model.yml index 03439408526d02e7a14329e075514bb73cf783f9..e698909bfbad21196b239f60123013887bb4524b 100644 --- a/integrationtests/full_test/model.yml +++ b/integrationtests/full_test/model.yml @@ -21,6 +21,8 @@ Person: responsible: responsible: datatype: REFERENCE +revisionOf: + datatype: REFERENCE results: datatype: REFERENCE source: diff --git a/integrationtests/full_test/test_crawler.py b/integrationtests/full_test/test_crawler.py index 3ea612eaf8821f6f2bb15ba353e125edba75504d..105e98f2d8b184cb9ec128998e9619aa099aeffc 100755 --- a/integrationtests/full_test/test_crawler.py +++ b/integrationtests/full_test/test_crawler.py @@ -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"