Skip to content

Commit 36ce790

Browse files
committed
Ensure test module imports function correctly
Added path adjustments in test modules to modify the sys.path, ensuring proper imports of project modules in test cases. This change allows the test suites to locate and use necessary package imports correctly from the source directory. No functional changes were made to the test logic or business logic. This addresses issues arising from import errors when running tests in isolated environments.
1 parent 3410574 commit 36ce790

File tree

7 files changed

+53
-19
lines changed

7 files changed

+53
-19
lines changed

src/tests/test_appearance.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import sys
2+
import os
3+
4+
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
5+
16
from processpiper import ProcessMap, EventType, ActivityType, GatewayType
27
from util_test import get_test_file_path
38

src/tests/test_bpmn.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import re
22
import xml.etree.ElementTree as ET
3+
import sys
4+
import os
5+
6+
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
37

48
from processpiper import ProcessMap, EventType, ActivityType, GatewayType
59
from util_test import get_test_file_path, get_solution_file_path, mock_uuid

src/tests/test_case01.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
import sys
2+
import os
3+
4+
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
5+
16
from processpiper import ProcessMap, EventType, ActivityType, GatewayType
27
from util_test import get_test_file_path
38

49

510
def test_case01():
611
with ProcessMap(
7-
"Pizza Order Process", colour_theme="BLUEMOUNTAIN"
12+
"Pizza Order Process", colour_theme="BLUEMOUNTAIN"
813
) as my_process_map:
914
with my_process_map.add_lane("Customer") as lane1:
1015
start = lane1.add_element("start", EventType.START)
@@ -45,7 +50,7 @@ def test_case01():
4550

4651
def test_case02():
4752
with ProcessMap(
48-
"Sample Test Process", colour_theme="BLUEMOUNTAIN"
53+
"Sample Test Process", colour_theme="BLUEMOUNTAIN"
4954
) as my_process_map:
5055
with my_process_map.add_lane("End User") as lane1:
5156
start = lane1.add_element("Start", EventType.START)

src/tests/test_processmapper.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import sys
2+
import os
3+
4+
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
5+
16
from processpiper import ProcessMap, EventType, ActivityType, GatewayType
27
from processpiper.coordinate import Side
38
from util_test import get_test_file_path
@@ -29,7 +34,7 @@ def test_case1():
2934

3035
def test_case2():
3136
with ProcessMap(
32-
"Product Order Processing", colour_theme="BLUEMOUNTAIN"
37+
"Product Order Processing", colour_theme="BLUEMOUNTAIN"
3338
) as my_process_map:
3439
with my_process_map.add_lane("Customer") as lane1:
3540
start = lane1.add_element("Start", EventType.START)
@@ -153,7 +158,7 @@ def test_case4():
153158

154159
def test_case5():
155160
with ProcessMap(
156-
"Sample Test Process", colour_theme="BLUEMOUNTAIN"
161+
"Sample Test Process", colour_theme="BLUEMOUNTAIN"
157162
) as my_process_map:
158163
with my_process_map.add_lane("End User") as lane1:
159164
start = lane1.add_element("Start", EventType.START)
@@ -287,7 +292,7 @@ def test_case9():
287292

288293
def test_case10(colour_theme: str = "BLUEMOUNTAIN"):
289294
with ProcessMap(
290-
"Shipment Process of a Hardware Retailer", colour_theme=colour_theme
295+
"Shipment Process of a Hardware Retailer", colour_theme=colour_theme
291296
) as my_process_map:
292297
with my_process_map.add_pool("Hardware Retailer") as pool1:
293298
with pool1.add_lane("Logistics Manager") as lane1:

src/tests/test_promo.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import sys
2+
import os
3+
4+
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
5+
16
from processpiper import text2diagram
27
from util_test import get_test_file_path
38

@@ -10,12 +15,10 @@ def manual_test_promo():
1015
(start) as start
1116
[Enter Keyword] as enter_keyword
1217
(end) as end
13-
18+
1419
start->enter_keyword->end
1520
"""
1621

1722
output_file = get_test_file_path("test_promo_01.png")
1823

19-
text2diagram.render(
20-
input_syntax, output_file, show_code=True
21-
)
24+
text2diagram.render(input_syntax, output_file, show_code=True)

src/tests/test_sample.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import sys
2+
import os
3+
4+
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
15
import pytest
26

37
from processpiper import ProcessMap, EventType, ActivityType, GatewayType
@@ -8,7 +12,7 @@
812

913
def test_sample01():
1014
with ProcessMap(
11-
"debug01", colour_theme="BLUEMOUNTAIN", width=8192
15+
"debug01", colour_theme="BLUEMOUNTAIN", width=8192
1216
) as my_process_map:
1317
with my_process_map.add_lane("customer") as lane1:
1418
start = lane1.add_element("start", EventType.START)
@@ -74,7 +78,7 @@ def test_sample01():
7478

7579
def test_sample02():
7680
with ProcessMap(
77-
"debug", colour_theme="BLUEMOUNTAIN", width=10000
81+
"debug", colour_theme="BLUEMOUNTAIN", width=10000
7882
) as my_process_map:
7983
with my_process_map.add_pool("Pool") as pool1:
8084
with pool1.add_lane("lane1") as lane1:
@@ -114,7 +118,7 @@ def test_sample02():
114118

115119
def test_sample03():
116120
with ProcessMap(
117-
"Break Glass Process", colour_theme="BLUEMOUNTAIN"
121+
"Break Glass Process", colour_theme="BLUEMOUNTAIN"
118122
) as my_process_map:
119123
with my_process_map.add_pool("Organisation") as pool1:
120124
with pool1.add_lane("ProductA User") as lane1:
@@ -193,7 +197,7 @@ def test_sample03():
193197

194198
def test_sample04():
195199
with ProcessMap(
196-
"Break Glass Process", colour_theme="BLUEMOUNTAIN", painter_type="SVG"
200+
"Break Glass Process", colour_theme="BLUEMOUNTAIN", painter_type="SVG"
197201
) as my_process_map:
198202
with my_process_map.add_pool("Organisation") as pool1:
199203
with pool1.add_lane("ProductA User") as lane1:
@@ -273,7 +277,9 @@ def test_sample04():
273277
def test_sample05():
274278
with pytest.raises(TooManyConnectionsException):
275279
with ProcessMap(
276-
"Test Max Connection Process", colour_theme="BLUEMOUNTAIN", painter_type="SVG"
280+
"Test Max Connection Process",
281+
colour_theme="BLUEMOUNTAIN",
282+
painter_type="SVG",
277283
) as my_process_map:
278284
with my_process_map.add_lane("Test Lane") as lane1:
279285
start = lane1.add_element("start", EventType.START)
@@ -303,7 +309,9 @@ def test_sample05():
303309
def test_sample06():
304310
with pytest.raises(TooManyConnectionsException):
305311
with ProcessMap(
306-
"Test Max Connection Process", colour_theme="BLUEMOUNTAIN", painter_type="SVG"
312+
"Test Max Connection Process",
313+
colour_theme="BLUEMOUNTAIN",
314+
painter_type="SVG",
307315
) as my_process_map:
308316
with my_process_map.add_lane("Test Lane") as lane1:
309317
start = lane1.add_element("start", EventType.START)
@@ -343,7 +351,7 @@ def test_sample06():
343351

344352
def test_sample07():
345353
with ProcessMap(
346-
"Product Feature Interface", colour_theme="BLUEMOUNTAIN"
354+
"Product Feature Interface", colour_theme="BLUEMOUNTAIN"
347355
) as my_process_map:
348356
with my_process_map.add_lane("system") as lane_system:
349357
node_start = lane_system.add_element("start", EventType.START)
@@ -415,7 +423,7 @@ def test_sample07():
415423
g3.connect(node_Update_Figma_Design_, "")
416424

417425
with pool_Product_How.add_lane(
418-
"Brokerage Squad; UXD"
426+
"Brokerage Squad; UXD"
419427
) as lane_Product_How_Brokerage_Squad__UXD:
420428
node_Work_with_Domains_SL = lane_Product_How_Brokerage_Squad__UXD.add_element(
421429
"Work with Domains SL (Bob\nTaiani, Chris Coale) to\ndevelop features UI stories",
@@ -437,7 +445,7 @@ def test_sample07():
437445
g4.connect(node_Create_feature_test_, "")
438446

439447
with pool_Product_How.add_lane(
440-
"Brokerage Squad"
448+
"Brokerage Squad"
441449
) as lane_Product_How_Brokerage_Squad:
442450
node_Implement_feature_UI = (
443451
lane_Product_How_Brokerage_Squad.add_element(
@@ -588,7 +596,7 @@ def test_sample10():
588596

589597
def test_sample11():
590598
with ProcessMap(
591-
"Are we living in simulation?", colour_theme="TEALWATERS"
599+
"Are we living in simulation?", colour_theme="TEALWATERS"
592600
) as process_map:
593601
with process_map.add_pool("The World") as pool:
594602
with pool.add_lane("You") as you:

src/tests/test_text2diagram.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import sys
2+
import os
3+
4+
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
15
from processpiper import text2diagram
26
from util_test import get_test_file_path
37

0 commit comments

Comments
 (0)