-
Notifications
You must be signed in to change notification settings - Fork 2
/
testscript.py
41 lines (32 loc) · 1.45 KB
/
testscript.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import unittest
import filecmp
import os
from edmlib import *
# inputFile is the datamart used for testing functions
entries = 4000
inputFile = 'sample/sample-datamart-' + str(entries) + '.csv'
data = gradeData(inputFile)
data.defineWorkingColumns("OTCM_FinalGradeN", "SID", "REG_term", "REG_CourseCrn", "REG_Programcode", "REG_Numbercode", "GRA_MajorAtGraduation", "STU_ulevel", "REG_REG_credHr")
data2 = classCorrelationData(inputFile)
class TestCorrelationData(unittest.TestCase):
def test_entries_num(self):
"""
Test that it can return the number of entries
"""
result = data2.getEntryCount()
self.assertEqual(result, entries)
class TestGradeData(unittest.TestCase):
def test_correlation_matrix(self):
"""
Test that the correlation matrix generated is correct
"""
exportFile = 'TempMatrix_' + str(entries) + '.csv'
data.exportCorrelationsWithMinNSharedStudents(filename=exportFile)
# correctFile is the file path of the supposedly correct output
correctFile = '../CorrelationMatrix/Output Correlation Matrices/CorrelationOutput_' + str(entries) + '.csv'
#correctFile = '../CorrelationMatrix/Output Correlation Matrices/CorrelationOutput_300.csv'
testBool = filecmp.cmp(exportFile, correctFile, False)
self.assertTrue(testBool)
os.remove(exportFile) # clean up the temporary export file
if __name__ == '__main__':
unittest.main()