From b247d7e4b2a843928855075a8c9beb4be2e0325c Mon Sep 17 00:00:00 2001
From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu>
Date: Fri, 31 Jul 2020 14:03:18 -0500
Subject: [PATCH] Move expected assigned into ci.yml #27

---
 .gitlab-ci.yml                     | 25 +++++++++++++++++++------
 workflow/tests/test_consistency.py | 22 ++++++++++------------
 2 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2871cf7..b36504f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -133,13 +133,13 @@ integration_se:
   - hostname
   - ulimit -a
   - nextflow -q run ./workflow/rna-seq.nf --deriva ./test_data/auth/credential.json --bdbag ./test_data/auth/cookies.txt --repRID 16-1ZX4 -with-dag dag.png --ci true
-  - find . -type f -name "multiqc_data.json" -exec cp {} ./16-1ZX4_multiqc_data.json \;
+  - find . -type f -name "multiqc_data.json" -exec cp {} ./SE_multiqc_data.json \;
   artifacts:
     name: "$CI_JOB_NAME"
     when: always
     paths:
       - output/qc/
-      - 16-1ZX4_multiqc_data.json
+      - SE_multiqc_data.json
     expire_in: 7 days
 
 integration_pe:
@@ -148,21 +148,34 @@ integration_pe:
   - hostname
   - ulimit -a
   - nextflow -q run ./workflow/rna-seq.nf --deriva ./test_data/auth/credential.json --bdbag ./test_data/auth/cookies.txt --repRID Q-Y5JA -with-dag dag.png --ci true
-  - find . -type f -name "multiqc_data.json" -exec cp {} ./Q-Y5JA_multiqc_data.json \;
+  - find . -type f -name "multiqc_data.json" -exec cp {} ./PE_multiqc_data.json \;
   artifacts:
     name: "$CI_JOB_NAME"
     when: always
     paths:
       - dag.png
       - output/qc/
-      - Q-Y5JA_multiqc_data.json
+      - PE_multiqc_data.json
     expire_in: 7 days
 
 consistency:
   stage: consistency
   script:
-  - 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
+  - grep -m 1 \"Assigned\":.[0-9] SE_multiqc_data.json | grep -oe '\([0-9.]*\)' > assignedSE.txt
+  - grep -m 1 \"Assigned\":.[0-9] PE_multiqc_data.json | grep -oe '\([0-9.]*\)' > assignedPE.txt
+  - echo 7742416 > assignedExpectSE.txt
+  - echo 2599149 > assignedExpectPE.txt
   - pytest -m consistencySE
   - pytest -m consistencyPE
+  artifacts:
+    name: "$CI_JOB_NAME"
+    when: always
+    paths:
+      - SE_multiqc_data.json
+      - PE_multiqc_data.json
+      - assignedSE.txt
+      - assignedPE.txt
+      - assignedExpectSE.txt
+      - assignedExpectPE.txt
+    expire_in: 7 days
 
diff --git a/workflow/tests/test_consistency.py b/workflow/tests/test_consistency.py
index 4526aa9..7659290 100644
--- a/workflow/tests/test_consistency.py
+++ b/workflow/tests/test_consistency.py
@@ -7,26 +7,24 @@ 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)
+    assert os.path.exists(os.path.join(test_output_path, 'SE_multiqc_data.json'))
+    assert readAssigned("assignedSE.txt","assignedExpectSE.txt")
 
 @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)
+    assert os.path.exists(os.path.join(test_output_path, 'PE_multiqc_data.json'))
+    assert readAssigned("assignedPE.txt","assignedExpectPE.txt")
 
-def readAssgned(assignedFile,assigned):
+def readAssgned(fileAssigned,fileExpectAssigned):
     data = False
-    file = open(assignedFile, "r")
-    line = file.readline()
-    if line.strip() == assigned:
+    assigned = open(fileAssigned, "r")
+    expect = open(fileExpectAssigned, "r")
+    lineAssigned = assigned.readline()
+    lineExpect = expect.readline()
+    if lineAssigned.strip() == lineExpect.strip():
         data = True
 
     return data
-- 
GitLab