From 3f55fde3e56a94f6748b8884c0b8187389b4fc77 Mon Sep 17 00:00:00 2001
From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu>
Date: Fri, 31 Jul 2020 13:43:33 -0500
Subject: [PATCH] Add consistency tests #27

---
 .gitlab-ci.yml                     |  7 +++++--
 workflow/tests/test_consistency.py | 32 ++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 workflow/tests/test_consistency.py

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 51e7758..2871cf7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -158,8 +158,11 @@ integration_pe:
       - Q-Y5JA_multiqc_data.json
     expire_in: 7 days
 
-consistency_se:
+consistency:
   stage: consistency
   script:
-  - echo "TEST"
+  - grep -m 1 \"Assigned\":.[0-9] 16-1ZX4_multiqc_data.json | grep -oe '\([0-9.]*\)' > assignedSE.txt
+  - grep -m 1 \"Assigned\":.[0-9] Q-Y5JA_multiqc_data.json | grep -oe '\([0-9.]*\)' > assignedPE.txt
+  - pytest -m consistencySE
+  - pytest -m consistencyPE
 
diff --git a/workflow/tests/test_consistency.py b/workflow/tests/test_consistency.py
new file mode 100644
index 0000000..4526aa9
--- /dev/null
+++ b/workflow/tests/test_consistency.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+
+import pytest
+import pandas as pd
+from io import StringIO
+import os
+
+test_output_path = os.path.dirname(os.path.abspath(__file__)) + \
+                '/../../'
+test_sampleSE = '16-1ZX4'
+test_assignededSE = '7742416'
+test_samplePE = 'Q-Y5JA'
+test_assignedPE = '2599149'
+
+@pytest.mark.consistencySE
+def test_consistencySE():
+    assert os.path.exists(os.path.join(test_output_path, test_sampleSE, '_multiqc_data.json'))
+    assert readAssigned("assignedSE.txt",test_assignedSE)
+
+@pytest.mark.consistencyPE
+def test_consistencyPE():
+    assert os.path.exists(os.path.join(test_output_path, test_samplePE, '_multiqc_data.json'))
+    assert readAssigned("assignedPE.txt",test_assignedPE)
+
+def readAssgned(assignedFile,assigned):
+    data = False
+    file = open(assignedFile, "r")
+    line = file.readline()
+    if line.strip() == assigned:
+        data = True
+
+    return data
-- 
GitLab