Commit 549e7cd0 authored by aknecht2's avatar aknecht2
Browse files

Added new tests. Added all sample verification.

parent 0a181c3f
......@@ -22,6 +22,33 @@ class MongoDB(object):
return
def check_valid_samples(self):
cursor = self.db.experiments.aggregate([
{
"$match": {
"target": {"$exists": True},
"revoked_files.0": {"$exists": False},
"assembly.0": {"$exists": True},
"assembly.1": {"$exists": False}
}
},
{
"$lookup": {
"from": "samples",
"localField": "_id",
"foreignField": "experiment_id",
"as": "samples"
}
}
])
total = 0
has_samples = 0
for document in cursor:
total += 1
if len(document["samples"]) > 0:
has_samples += 1
return (has_samples, total)
def get_samples(self, experiment_id):
valid = True
msg = ""
......
......@@ -75,12 +75,23 @@ def exp_files_test_3():
print_test("Exp_Files_Test_3", not valid and msg == "Experiment with id 'ENCSR329RIP' does not have all required metadata (assembly, target, no revoked_files).")
return
# Test8, multiple control experiments, no possible control_inputs
# Test8, multiple control experiments
def exp_files_test_4():
valid, msg, data = mdb.get_samples("ENCSR000CWZ")
print_test("Exp_Files_Test_4", valid and msg == "Succesfully retrieved input files for experiment with id 'ENCSR000CWZ'." and len(data["control"]) == 4 and len(data["experiment"]) == 2)
return
# Test9, multiple control experiments, no possible control_inputs
def exp_files_test_5():
valid, msg, data = mdb.get_samples("ENCSR000DKB")
print_test("Exp_Files_Test_5", not valid and msg == "Experiment with id 'ENCSR000DKB' has '0' possible control inputs, and '3' possible experiment inputs.")
return
def valid_samples():
has_samples, total = mdb.check_valid_samples()
print_test("Verify_All_Samples", has_samples == total)
return
tests = [
......@@ -91,7 +102,9 @@ tests = [
exp_files_test_1,
exp_files_test_2,
exp_files_test_3,
exp_files_test_4
exp_files_test_4,
exp_files_test_5,
valid_samples
]
for test in tests:
test()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment