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

update tests

parent cea47900
No related branches found
No related tags found
No related merge requests found
Showing
with 162 additions and 24 deletions
......@@ -56,7 +56,7 @@ if __name__ == "__main__":
print("Query done...")
config = db.configuration.get_config()
c = Crawler(use_cache=True, access=access,
verbosity=INFO,
verbosity=DEBUG,
food=[ProjectCFood,
AnalysisCFood, ExperimentCFood,
PublicationCFood, SimulationCFood,
......
......
......@@ -3,7 +3,7 @@ responsible:
- Only Responsible
description: A description of another example analysis.
data:
source:
- filename: "/ExperimentalData/TestProject/2019-02-03/*.dat"
description: an example reference to a results file
......
......
......@@ -7,9 +7,12 @@ results:
- filename: "images/*.png"
description: an example reference to a results file
data:
- filename: /ExperimentalData/TestProject/2019-02-03_something/use*.xlsx
description: an example reference to data files
source:
- filename: /ExperimentalData/TestProject/2019-02-03_something/
description: an example reference to an experiment
revisionOf:
- ../2019-02-03
scripts:
- analyse.py
......
......
......@@ -3,7 +3,9 @@ responsible:
- Only Responsible
description: A description of another example experiment.
source:
- /home/professional/CaosDB/caosdb-deploy/profiles/empty/custom/extroot/DataAnalysis/TestProject/2019-02-03/results.pdf
results:
- filename: "/ExperimentalData/TestProject/2019-02-03/*.dat"
description: an example reference to a results file
- "*.pdf"
...
---
responsible:
- First Person
- Second Person
description: A description of an example experiment.
results:
- filename: "*.xlsx"
description: an example reference to a results file
tags:
- collagen
......
......
......@@ -4,6 +4,9 @@ responsible:
description: A description of another example experiment.
results:
- filename: "/ExperimentalData/TestProject/2019-02-03/*.dat"
- filename: "*.dat"
description: an example reference to a results file
scripts:
- sim.py
...
......@@ -5,8 +5,18 @@ responsible:
description: A description of an example experiment.
results:
- filename: "*.xlsx"
description: an example reference to a results file
- filename: "*.npy"
description: time series
scripts:
- "parameters.p"
- "large_sim.py"
revisonOf:
- ../2019-02-03
source:
- /extroot/ExperimentalData/TestProject/2019-02-03
tags:
- collagen
......
......
......@@ -30,8 +30,19 @@ class CrawlerTest(unittest.TestCase):
# There should be a datafile as result attached with path datafile.dat
datfile_id = exp.get_property("results").value[0]
datfile = get_entity_with_id(datfile_id)
self.assertEqual("A description of another example experiment.",
datfile.description)
assert os.path.basename(datfile.path) == "datafile.dat"
# Should have a responsible person
self.assertIsNotNone(exp.get_property("Responsible"))
person = db.Record(id=exp.get_property("Responsible").value)
person.retrieve()
self.assertEqual("Only", person.get_property("FirstName").value)
# Should have a description
self.assertIsNotNone(exp.description)
#########################
# # second experiment # #
#########################
......@@ -75,6 +86,28 @@ class CrawlerTest(unittest.TestCase):
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "plot.py"
# There should be a file as script attached with path plot.py
datfile_id = ana.get_property("source").value[0]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "datafile.dat"
self.assertEqual(datfile.description,
"an example reference to a results file")
# Should have a responsible person
self.assertIsNotNone(ana.get_property("Responsible"))
person = db.Record(id=ana.get_property("Responsible").value)
person.retrieve()
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"))
person = db.Record(id=ana.get_property("Responsible").value)
person.retrieve()
self.assertEqual("2019-02-03", person.get_property("date").value)
#######################
# # second analysis # #
#######################
......@@ -85,30 +118,120 @@ class CrawlerTest(unittest.TestCase):
# Should be the same project
assert project_id == ana.get_property("Project").value
# Should have two data files
datfile_ids = ana.get_property("results").value
datafile_names = []
# There should be a file as script attached with path plot.py
datfile_id = ana.get_property("scripts").value[0]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "analyse.py"
for did in datfile_ids:
datfile = get_entity_with_id(did)
datafile_names.append(os.path.basename(datfile.path))
assert "lol1.png" in datafile_names
assert "lol2.png" in datafile_names
# Should reference an experiment
self.assertIsNotNone(ana.get_property("Experiment"))
person = db.Record(id=ana.get_property("Responsible").value)
person.retrieve()
self.assertEqual("2019-02-03", person.get_property("date").value)
def test_simulation(self):
######################
# # first simulation # #
######################
sim = db.execute_query(
"FIND Simulation with date=2019-02-03 and identifier='empty_identifier'",
unique=True)
# There should be a Project with name TestProject which is referenced
project_id = sim.get_property("Project").value
project = get_entity_with_id(project_id)
assert "Project" in [p.name for p in project.get_parents()]
# There should be a file as result attached with path results.pdf
datfile_id = sim.get_property("results").value[0]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "snapshots.dat"
# There should be a file as script attached with path plot.py
datfile_id = ana.get_property("scripts").value[0]
datfile_id = sim.get_property("scripts").value[0]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "sim.py"
# Should have a responsible person
self.assertIsNotNone(sim.get_property("Responsible"))
person = db.Record(id=sim.get_property("Responsible").value)
person.retrieve()
self.assertEqual("Only", person.get_property("FirstName").value)
# Should have a description
self.assertIsNotNone(sim.description)
#########################
# # second simulation # #
#########################
sim = db.execute_query(
"FIND Simulation with date=2019-02-03 and identifier='something'",
unique=True)
# There should be a file as script attached with path plot.py
exp = get_entity_with_id(sim.get_property("source").value)
self.assertEqual(exp.parents[0].name, "Experiment")
# Should be the same project
assert project_id == sim.get_property("Project").value
# Should have two responsible persons
self.assertIsNotNone(sim.get_property("Responsible"))
self.assertEqual(len(sim.get_property("Responsible").value), 2)
# 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)
# Should have data file
datfile_id = sim.get_property("results").value[0]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "timeseries.npy"
# There should be a file as script attached with path plot.py
datfile_id = sim.get_property("scripts").value[0]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "analyse.py"
# Should have two scritps files
datfile_ids = exp.get_property("scripts").value
datafile_names = []
for did in datfile_ids:
datfile = get_entity_with_id(did)
datafile_names.append(os.path.basename(datfile.path))
assert "parameters.p" in datafile_names
assert "large_sim.py" in datafile_names
def test_publication(self):
#########################
# # first publication # #
#########################
pub = db.execute_query("FIND *really_cool_finding", unique=True)
# There should be a Project with name TestProject which is referenced
# There should be a file as result attached with path results.pdf
datfile_id = pub.get_property("results").value[0]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "poster.pdf"
# There should be a file as data attached with path plot.py
datfile_id = pub.get_property("sources").value[0]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "results.pdf"
# Test type
self.assertEqual(pub.parents[0].name, "Poster")
##########################
# # second publication # #
##########################
pub = db.execute_query("FIND *paper_on_exciting_stuff ", unique=True)
# There should be a file as data attached with path plot.py
datfile_id = pub.get_property("sources").value[0]
datfile = get_entity_with_id(datfile_id)
assert os.path.basename(datfile.path) == "results.pdf"
# Test type
self.assertEqual(pub.parents[0].name, "Poster")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment