Skip to content

Commit a5215b6

Browse files
Updated travis config -> fixed paths for tests
1 parent 5954a3c commit a5215b6

File tree

5 files changed

+126
-127
lines changed

5 files changed

+126
-127
lines changed

tests/functional_tests/test__cmd_line.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
from pypiscout.SCout_Logger import Logger as sc
2828
from matplotlib import pyplot as plt
2929

30-
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "Emma"))
30+
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
3131
# pylint: disable=wrong-import-position
3232
# Rationale: This module needs to access modules that are above them in the folder structure.
3333

34-
import emma
35-
import emma_vis
36-
from shared_libs.stringConstants import * # pylint: disable=unused-wildcard-import,wildcard-import
34+
import Emma.emma
35+
import Emma.emma_vis
36+
from Emma.shared_libs.stringConstants import * # pylint: disable=unused-wildcard-import,wildcard-import
3737

3838

3939
class TestHelper(unittest.TestCase):
@@ -122,8 +122,8 @@ def test_normalRun(self):
122122
Check that an ordinary run is successful
123123
"""
124124
try:
125-
args = emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.cmdLineTestProjectMapfilesFolder, "--dir", self.cmdLineTestOutputFolder])
126-
emma.main(args)
125+
args = Emma.emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.cmdLineTestProjectMapfilesFolder, "--dir", self.cmdLineTestOutputFolder])
126+
Emma.emma.main(args)
127127
except Exception as e: # pylint: disable=broad-except
128128
# Rationale: The purpose here is to catch any exception.
129129
self.fail("Unexpected exception: " + str(e))
@@ -133,44 +133,44 @@ def test_help(self):
133133
Check that `--help` does not raise an exception but exits with SystemExit(0)
134134
"""
135135
with self.assertRaises(SystemExit) as context:
136-
args = emma.parseArgs(["--help"])
137-
emma.main(args)
136+
args = Emma.emma.parseArgs(["--help"])
137+
Emma.emma.main(args)
138138
self.assertEqual(context.exception.code, 0)
139139

140140
def test_unrecognisedArgs(self):
141141
"""
142142
Check that an unexpected argument does raise an exception
143143
"""
144144
with self.assertRaises(SystemExit) as context:
145-
args = emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.cmdLineTestProjectMapfilesFolder, "--dir", self.cmdLineTestOutputFolder, "--blahhhhhh"])
146-
emma.main(args)
145+
args = Emma.emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.cmdLineTestProjectMapfilesFolder, "--dir", self.cmdLineTestOutputFolder, "--blahhhhhh"])
146+
Emma.emma.main(args)
147147
self.assertEqual(context.exception.code, 2)
148148

149149
def test_noProjDir(self):
150150
"""
151151
Check run with non-existing project folder
152152
"""
153153
with self.assertRaises(SystemExit) as context:
154-
args = emma.parseArgs(["--project", self.nonExistingPath, "--mapfiles", self.cmdLineTestProjectMapfilesFolder, "--dir", self.cmdLineTestOutputFolder])
155-
emma.main(args)
154+
args = Emma.emma.parseArgs(["--project", self.nonExistingPath, "--mapfiles", self.cmdLineTestProjectMapfilesFolder, "--dir", self.cmdLineTestOutputFolder])
155+
Emma.emma.main(args)
156156
self.assertEqual(context.exception.code, -10)
157157

158158
def test_noMapfileDir(self):
159159
"""
160160
Check run with non-existing mapfile folder
161161
"""
162162
with self.assertRaises(SystemExit) as context:
163-
args = emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.nonExistingPath, "--dir", self.cmdLineTestOutputFolder])
164-
emma.main(args)
163+
args = Emma.emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.nonExistingPath, "--dir", self.cmdLineTestOutputFolder])
164+
Emma.emma.main(args)
165165
self.assertEqual(context.exception.code, -10)
166166

167167
def test_noDirOption(self):
168168
"""
169169
Check run without a --dir parameter
170170
"""
171171
try:
172-
args = emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.cmdLineTestProjectMapfilesFolder])
173-
emma.main(args)
172+
args = Emma.emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.cmdLineTestProjectMapfilesFolder])
173+
Emma.emma.main(args)
174174
except Exception as e: # pylint: disable=broad-except
175175
# Rationale: The purpose here is to catch any exception.
176176
self.fail("Unexpected exception: " + str(e))
@@ -198,18 +198,18 @@ def runEmma(self, outputFolder=None):
198198
:return: None
199199
"""
200200
if outputFolder is not None:
201-
args = emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.cmdLineTestProjectMapfilesFolder, "--dir", outputFolder, "--noprompt"])
201+
args = Emma.emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.cmdLineTestProjectMapfilesFolder, "--dir", outputFolder, "--noprompt"])
202202
else:
203-
args = emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.cmdLineTestProjectMapfilesFolder, "--noprompt"])
204-
emma.main(args)
203+
args = Emma.emma.parseArgs(["--project", self.cmdLineTestProjectFolder, "--mapfiles", self.cmdLineTestProjectMapfilesFolder, "--noprompt"])
204+
Emma.emma.main(args)
205205

206206
def test_normalRun(self):
207207
"""
208208
Check that an ordinary run is successful
209209
"""
210210
try:
211-
argsEmmaVis = emma_vis.parseArgs(["--project", self.cmdLineTestProjectFolder, "--overview", "--inOutDir", self.cmdLineTestOutputFolder, "--noprompt", "--quiet"])
212-
emma_vis.main(argsEmmaVis)
211+
argsEmmaVis = Emma.emma_vis.parseArgs(["--project", self.cmdLineTestProjectFolder, "--overview", "--inOutDir", self.cmdLineTestOutputFolder, "--noprompt", "--quiet"])
212+
Emma.emma_vis.main(argsEmmaVis)
213213
except Exception as e: # pylint: disable=broad-except
214214
# Rationale: The purpose here is to catch any exception.
215215
self.fail("Unexpected exception: " + str(e))
@@ -219,35 +219,35 @@ def test_help(self):
219219
Check that `--help` does not raise an exception but exits with SystemExit(0)
220220
"""
221221
with self.assertRaises(SystemExit) as context:
222-
args = emma_vis.parseArgs(["--help"])
223-
emma_vis.main(args)
222+
args = Emma.emma_vis.parseArgs(["--help"])
223+
Emma.emma_vis.main(args)
224224
self.assertEqual(context.exception.code, 0)
225225

226226
def test_unrecognisedArgs(self):
227227
"""
228228
Check that an unexpected argument does raise an exception
229229
"""
230230
with self.assertRaises(SystemExit) as context:
231-
args = emma_vis.parseArgs(["--project", self.cmdLineTestProjectFolder, "overview", "--dir", self.cmdLineTestOutputFolder, "--blahhhhhh", "--noprompt", "--quiet"])
232-
emma_vis.main(args)
231+
args = Emma.emma_vis.parseArgs(["--project", self.cmdLineTestProjectFolder, "overview", "--dir", self.cmdLineTestOutputFolder, "--blahhhhhh", "--noprompt", "--quiet"])
232+
Emma.emma_vis.main(args)
233233
self.assertEqual(context.exception.code, 2)
234234

235235
def test_noProjDir(self):
236236
"""
237237
Check run with non-existing project folder
238238
"""
239239
with self.assertRaises(SystemExit) as context:
240-
args = emma_vis.parseArgs(["--project", self.nonExistingPath, "--overview", "--inOutDir", self.cmdLineTestOutputFolder, "--noprompt", "--quiet"])
241-
emma_vis.main(args)
240+
args = Emma.emma_vis.parseArgs(["--project", self.nonExistingPath, "--overview", "--inOutDir", self.cmdLineTestOutputFolder, "--noprompt", "--quiet"])
241+
Emma.emma_vis.main(args)
242242
self.assertEqual(context.exception.code, -10)
243243

244244
def test_noMemStats(self):
245245
"""
246246
Check run with non-existing memStats folder
247247
"""
248248
with self.assertRaises(SystemExit) as context:
249-
args = emma_vis.parseArgs(["--project", self.cmdLineTestProjectFolder, "--overview", "--inOutDir", self.nonExistingPath, "--noprompt", "--quiet"])
250-
emma_vis.main(args)
249+
args = Emma.emma_vis.parseArgs(["--project", self.cmdLineTestProjectFolder, "--overview", "--inOutDir", self.nonExistingPath, "--noprompt", "--quiet"])
250+
Emma.emma_vis.main(args)
251251
self.assertEqual(context.exception.code, -10)
252252

253253
def test_noDirOption(self):
@@ -258,8 +258,8 @@ def test_noDirOption(self):
258258
# This a is a specific case, the default Emma results will not work here. Because of this, we will delete it and run the Emma again.
259259
shutil.rmtree(self.cmdLineTestOutputFolder)
260260
self.runEmma()
261-
args = emma_vis.parseArgs(["--project", self.cmdLineTestProjectFolder, "--overview", "--noprompt", "--quiet"])
262-
emma_vis.main(args)
261+
args = Emma.emma_vis.parseArgs(["--project", self.cmdLineTestProjectFolder, "--overview", "--noprompt", "--quiet"])
262+
Emma.emma_vis.main(args)
263263
plt.close('all')
264264
except Exception as e: # pylint: disable=broad-except
265265
# Rationale: The purpose here is to catch any exception.

tests/functional_tests/test__test_project.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
import pandas
2828

2929

30-
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "Emma"))
30+
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
3131
# pylint: disable=wrong-import-position
3232
# Rationale: This module needs to access modules that are above them in the folder structure.
3333

34-
from shared_libs.stringConstants import * # pylint: disable=unused-wildcard-import,wildcard-import
35-
import emma
34+
from Emma.shared_libs.stringConstants import * # pylint: disable=unused-wildcard-import,wildcard-import
35+
import Emma.emma
3636

3737
class EmmaTestProject(unittest.TestCase):
3838
# pylint: disable=invalid-name
@@ -65,8 +65,8 @@ def setUp(self):
6565
os.mkdir(self.resultsFolder)
6666

6767
# Running the test_project to create the CSV tables
68-
arguments = emma.parseArgs(["--project", testProjectFolder, "--mapfile", mapfilesFolder, "--dir", self.resultsFolder])
69-
emma.main(arguments)
68+
arguments = Emma.emma.parseArgs(["--project", testProjectFolder, "--mapfile", mapfilesFolder, "--dir", self.resultsFolder])
69+
Emma.emma.main(arguments)
7070

7171
for _, directories, files in os.walk(self.memStatsFolder):
7272
# The result folder shall have 0 subdirectories and three summary files

tests/unit_tests/test_emma_helper.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
from pypiscout.SCout_Logger import Logger as sc
2626

27-
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "Emma"))
27+
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
2828
# pylint: disable=wrong-import-position
2929
# Rationale: This module needs to access modules that are above them in the folder structure.
3030

31-
from shared_libs.stringConstants import * # pylint: disable=unused-wildcard-import,wildcard-import
32-
import shared_libs.emma_helper
31+
from Emma.shared_libs.stringConstants import * # pylint: disable=unused-wildcard-import,wildcard-import
32+
import Emma.shared_libs.emma_helper
3333

3434

3535
class EmmaHelperTestCase(unittest.TestCase):
@@ -50,28 +50,28 @@ def setUp(self):
5050

5151
def test_checkIfFolderExists(self):
5252
try:
53-
shared_libs.emma_helper.checkIfFolderExists(os.path.dirname(__file__))
53+
Emma.shared_libs.emma_helper.checkIfFolderExists(os.path.dirname(__file__))
5454
except Exception: # pylint: disable=broad-except
5555
# Rationale: The goal here is to catch any exception types.
5656
self.fail("Unexpected exception!")
5757
with self.assertRaises(SystemExit) as contextManager:
58-
shared_libs.emma_helper.checkIfFolderExists("DefinitelyNonExistingFolder")
58+
Emma.shared_libs.emma_helper.checkIfFolderExists("DefinitelyNonExistingFolder")
5959
self.assertEqual(contextManager.exception.code, "error")
6060

6161
def test_checkIfFileExists(self):
6262
try:
63-
shared_libs.emma_helper.checkIfFileExists(__file__)
63+
Emma.shared_libs.emma_helper.checkIfFileExists(__file__)
6464
except Exception: # pylint: disable=broad-except
6565
# Rationale: The goal here is to catch any exception types.
6666
self.fail("Unexpected exception!")
6767
with self.assertRaises(SystemExit) as contextManager:
68-
shared_libs.emma_helper.checkIfFileExists("DefinitelyNonExisting.file")
68+
Emma.shared_libs.emma_helper.checkIfFileExists("DefinitelyNonExisting.file")
6969
self.assertEqual(contextManager.exception.code, "error")
7070

7171
def test_mkDirIfNeeded(self):
7272
directoryName = "TestDirectoryNameThatShouldNotExist"
7373
self.assertFalse(os.path.isdir(directoryName))
74-
shared_libs.emma_helper.mkDirIfNeeded(directoryName)
74+
Emma.shared_libs.emma_helper.mkDirIfNeeded(directoryName)
7575
self.assertTrue(os.path.isdir(directoryName))
7676
os.rmdir(directoryName)
7777

@@ -81,10 +81,10 @@ def test_readJsonWriteJson(self):
8181

8282
jsonContentToWrite = {"TestDictionary": {}}
8383
jsonContentToWrite["TestDictionary"]["test_passed"] = True
84-
shared_libs.emma_helper.writeJson(jsonTestFilePath, jsonContentToWrite)
84+
Emma.shared_libs.emma_helper.writeJson(jsonTestFilePath, jsonContentToWrite)
8585
self.assertTrue(os.path.exists(jsonTestFilePath))
8686

87-
jsonContentReadIn = shared_libs.emma_helper.readJson(jsonTestFilePath)
87+
jsonContentReadIn = Emma.shared_libs.emma_helper.readJson(jsonTestFilePath)
8888
self.assertIn("TestDictionary", jsonContentReadIn)
8989
self.assertIn("test_passed", jsonContentReadIn["TestDictionary"])
9090
self.assertEqual(type(jsonContentReadIn["TestDictionary"]["test_passed"]), bool)
@@ -93,48 +93,48 @@ def test_readJsonWriteJson(self):
9393
self.assertFalse(os.path.exists(jsonTestFilePath))
9494

9595
def test_unifyAddress(self):
96-
hexResult, decResult = shared_libs.emma_helper.unifyAddress("0x16")
96+
hexResult, decResult = Emma.shared_libs.emma_helper.unifyAddress("0x16")
9797
self.assertEqual(hexResult, "0x16")
9898
self.assertEqual(decResult, 22)
99-
hexResult, decResult = shared_libs.emma_helper.unifyAddress(22)
99+
hexResult, decResult = Emma.shared_libs.emma_helper.unifyAddress(22)
100100
self.assertEqual(hexResult, "0x16")
101101
self.assertEqual(decResult, 22)
102102
with self.assertRaises(ValueError) as contextManager:
103-
hexResult, decResult = shared_libs.emma_helper.unifyAddress("Obviously not a number...")
103+
hexResult, decResult = Emma.shared_libs.emma_helper.unifyAddress("Obviously not a number...")
104104
with self.assertRaises(SystemExit) as contextManager:
105-
hexResult, decResult = shared_libs.emma_helper.unifyAddress(0.123)
105+
hexResult, decResult = Emma.shared_libs.emma_helper.unifyAddress(0.123)
106106
self.assertEqual(contextManager.exception.code, "error")
107107

108108
def test_getTimestampFromFilename(self):
109-
timestamp = shared_libs.emma_helper.getTimestampFromFilename("MyFile_2017-11-06-14h56s52.csv")
109+
timestamp = Emma.shared_libs.emma_helper.getTimestampFromFilename("MyFile_2017-11-06-14h56s52.csv")
110110
self.assertEqual(timestamp, "2017-11-06-14h56s52")
111111
with self.assertRaises(SystemExit) as contextManager:
112-
shared_libs.emma_helper.getTimestampFromFilename("MyFileWithoutTimeStamp.csv")
112+
Emma.shared_libs.emma_helper.getTimestampFromFilename("MyFileWithoutTimeStamp.csv")
113113
self.assertEqual(contextManager.exception.code, "error")
114114

115115
def test_toHumanReadable(self):
116-
self.assertEqual(" 0.00 B", shared_libs.emma_helper.toHumanReadable(0))
117-
self.assertEqual(" 10.00 B", shared_libs.emma_helper.toHumanReadable(10))
118-
self.assertEqual(" 1024.00 B", shared_libs.emma_helper.toHumanReadable(1024))
119-
self.assertEqual(" 1.00 KiB", shared_libs.emma_helper.toHumanReadable(1025))
120-
self.assertEqual(" 1.01 KiB", shared_libs.emma_helper.toHumanReadable(1035))
121-
self.assertEqual(" 1.10 KiB", shared_libs.emma_helper.toHumanReadable(1126))
122-
self.assertEqual(" 157.36 GiB", shared_libs.emma_helper.toHumanReadable(168963795964))
116+
self.assertEqual(" 0.00 B", Emma.shared_libs.emma_helper.toHumanReadable(0))
117+
self.assertEqual(" 10.00 B", Emma.shared_libs.emma_helper.toHumanReadable(10))
118+
self.assertEqual(" 1024.00 B", Emma.shared_libs.emma_helper.toHumanReadable(1024))
119+
self.assertEqual(" 1.00 KiB", Emma.shared_libs.emma_helper.toHumanReadable(1025))
120+
self.assertEqual(" 1.01 KiB", Emma.shared_libs.emma_helper.toHumanReadable(1035))
121+
self.assertEqual(" 1.10 KiB", Emma.shared_libs.emma_helper.toHumanReadable(1126))
122+
self.assertEqual(" 157.36 GiB", Emma.shared_libs.emma_helper.toHumanReadable(168963795964))
123123

124124
def test_evalSummary(self):
125-
self.assertEqual(shared_libs.emma_helper.evalSummary("Projectname_" + FILE_IDENTIFIER_SECTION_SUMMARY + "_2017-11-06-14h56s52.csv"), FILE_IDENTIFIER_SECTION_SUMMARY)
126-
self.assertEqual(shared_libs.emma_helper.evalSummary("Projectname_" + FILE_IDENTIFIER_OBJECT_SUMMARY + "_2017-11-06-14h56s52.csv"), FILE_IDENTIFIER_OBJECT_SUMMARY)
127-
self.assertIsNone(shared_libs.emma_helper.evalSummary("Projectname_" + "_2017-11-06-14h56s52.csv"))
125+
self.assertEqual(Emma.shared_libs.emma_helper.evalSummary("Projectname_" + FILE_IDENTIFIER_SECTION_SUMMARY + "_2017-11-06-14h56s52.csv"), FILE_IDENTIFIER_SECTION_SUMMARY)
126+
self.assertEqual(Emma.shared_libs.emma_helper.evalSummary("Projectname_" + FILE_IDENTIFIER_OBJECT_SUMMARY + "_2017-11-06-14h56s52.csv"), FILE_IDENTIFIER_OBJECT_SUMMARY)
127+
self.assertIsNone(Emma.shared_libs.emma_helper.evalSummary("Projectname_" + "_2017-11-06-14h56s52.csv"))
128128

129129
def test_projectNameFromPath(self):
130-
self.assertEqual("MyProject", shared_libs.emma_helper.projectNameFromPath(os.path.join("C:", "GitRepos", "Emma", "MyProject")))
130+
self.assertEqual("MyProject", Emma.shared_libs.emma_helper.projectNameFromPath(os.path.join("C:", "GitRepos", "Emma", "MyProject")))
131131

132132
def test_joinPath(self):
133133
if platform.system() == "Windows":
134-
self.assertEqual(r"c:Documents\Projects\Emma", shared_libs.emma_helper.joinPath("c:", "Documents", "Projects", "Emma"))
135-
self.assertEqual(r"..\..\Emma\tests\other_files", shared_libs.emma_helper.joinPath("..", "..", "Emma", "tests", "other_files"))
134+
self.assertEqual(r"c:Documents\Projects\Emma", Emma.shared_libs.emma_helper.joinPath("c:", "Documents", "Projects", "Emma"))
135+
self.assertEqual(r"..\..\Emma\tests\other_files", Emma.shared_libs.emma_helper.joinPath("..", "..", "Emma", "tests", "other_files"))
136136
elif platform.system() == "Linux":
137-
self.assertEqual(r"Documents/Projects/Emma", shared_libs.emma_helper.joinPath("Documents", "Projects", "Emma"))
138-
self.assertEqual(r"../../Emma/tests/other_files", shared_libs.emma_helper.joinPath("..", "..", "Emma", "tests", "other_files"))
137+
self.assertEqual(r"Documents/Projects/Emma", Emma.shared_libs.emma_helper.joinPath("Documents", "Projects", "Emma"))
138+
self.assertEqual(r"../../Emma/tests/other_files", Emma.shared_libs.emma_helper.joinPath("..", "..", "Emma", "tests", "other_files"))
139139
else:
140140
raise EnvironmentError("Unexpected platform value: " + platform.system())

0 commit comments

Comments
 (0)