Skip to content

Commit

Permalink
Ensure test module imports function correctly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
csgoh committed Nov 2, 2024
1 parent 3410574 commit 36ce790
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 19 deletions.
5 changes: 5 additions & 0 deletions src/tests/test_appearance.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from processpiper import ProcessMap, EventType, ActivityType, GatewayType
from util_test import get_test_file_path

Expand Down
4 changes: 4 additions & 0 deletions src/tests/test_bpmn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import re
import xml.etree.ElementTree as ET
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from processpiper import ProcessMap, EventType, ActivityType, GatewayType
from util_test import get_test_file_path, get_solution_file_path, mock_uuid
Expand Down
9 changes: 7 additions & 2 deletions src/tests/test_case01.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from processpiper import ProcessMap, EventType, ActivityType, GatewayType
from util_test import get_test_file_path


def test_case01():
with ProcessMap(
"Pizza Order Process", colour_theme="BLUEMOUNTAIN"
"Pizza Order Process", colour_theme="BLUEMOUNTAIN"
) as my_process_map:
with my_process_map.add_lane("Customer") as lane1:
start = lane1.add_element("start", EventType.START)
Expand Down Expand Up @@ -45,7 +50,7 @@ def test_case01():

def test_case02():
with ProcessMap(
"Sample Test Process", colour_theme="BLUEMOUNTAIN"
"Sample Test Process", colour_theme="BLUEMOUNTAIN"
) as my_process_map:
with my_process_map.add_lane("End User") as lane1:
start = lane1.add_element("Start", EventType.START)
Expand Down
11 changes: 8 additions & 3 deletions src/tests/test_processmapper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from processpiper import ProcessMap, EventType, ActivityType, GatewayType
from processpiper.coordinate import Side
from util_test import get_test_file_path
Expand Down Expand Up @@ -29,7 +34,7 @@ def test_case1():

def test_case2():
with ProcessMap(
"Product Order Processing", colour_theme="BLUEMOUNTAIN"
"Product Order Processing", colour_theme="BLUEMOUNTAIN"
) as my_process_map:
with my_process_map.add_lane("Customer") as lane1:
start = lane1.add_element("Start", EventType.START)
Expand Down Expand Up @@ -153,7 +158,7 @@ def test_case4():

def test_case5():
with ProcessMap(
"Sample Test Process", colour_theme="BLUEMOUNTAIN"
"Sample Test Process", colour_theme="BLUEMOUNTAIN"
) as my_process_map:
with my_process_map.add_lane("End User") as lane1:
start = lane1.add_element("Start", EventType.START)
Expand Down Expand Up @@ -287,7 +292,7 @@ def test_case9():

def test_case10(colour_theme: str = "BLUEMOUNTAIN"):
with ProcessMap(
"Shipment Process of a Hardware Retailer", colour_theme=colour_theme
"Shipment Process of a Hardware Retailer", colour_theme=colour_theme
) as my_process_map:
with my_process_map.add_pool("Hardware Retailer") as pool1:
with pool1.add_lane("Logistics Manager") as lane1:
Expand Down
11 changes: 7 additions & 4 deletions src/tests/test_promo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from processpiper import text2diagram
from util_test import get_test_file_path

Expand All @@ -10,12 +15,10 @@ def manual_test_promo():
(start) as start
[Enter Keyword] as enter_keyword
(end) as end
start->enter_keyword->end
"""

output_file = get_test_file_path("test_promo_01.png")

text2diagram.render(
input_syntax, output_file, show_code=True
)
text2diagram.render(input_syntax, output_file, show_code=True)
28 changes: 18 additions & 10 deletions src/tests/test_sample.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import pytest

from processpiper import ProcessMap, EventType, ActivityType, GatewayType
Expand All @@ -8,7 +12,7 @@

def test_sample01():
with ProcessMap(
"debug01", colour_theme="BLUEMOUNTAIN", width=8192
"debug01", colour_theme="BLUEMOUNTAIN", width=8192
) as my_process_map:
with my_process_map.add_lane("customer") as lane1:
start = lane1.add_element("start", EventType.START)
Expand Down Expand Up @@ -74,7 +78,7 @@ def test_sample01():

def test_sample02():
with ProcessMap(
"debug", colour_theme="BLUEMOUNTAIN", width=10000
"debug", colour_theme="BLUEMOUNTAIN", width=10000
) as my_process_map:
with my_process_map.add_pool("Pool") as pool1:
with pool1.add_lane("lane1") as lane1:
Expand Down Expand Up @@ -114,7 +118,7 @@ def test_sample02():

def test_sample03():
with ProcessMap(
"Break Glass Process", colour_theme="BLUEMOUNTAIN"
"Break Glass Process", colour_theme="BLUEMOUNTAIN"
) as my_process_map:
with my_process_map.add_pool("Organisation") as pool1:
with pool1.add_lane("ProductA User") as lane1:
Expand Down Expand Up @@ -193,7 +197,7 @@ def test_sample03():

def test_sample04():
with ProcessMap(
"Break Glass Process", colour_theme="BLUEMOUNTAIN", painter_type="SVG"
"Break Glass Process", colour_theme="BLUEMOUNTAIN", painter_type="SVG"
) as my_process_map:
with my_process_map.add_pool("Organisation") as pool1:
with pool1.add_lane("ProductA User") as lane1:
Expand Down Expand Up @@ -273,7 +277,9 @@ def test_sample04():
def test_sample05():
with pytest.raises(TooManyConnectionsException):
with ProcessMap(
"Test Max Connection Process", colour_theme="BLUEMOUNTAIN", painter_type="SVG"
"Test Max Connection Process",
colour_theme="BLUEMOUNTAIN",
painter_type="SVG",
) as my_process_map:
with my_process_map.add_lane("Test Lane") as lane1:
start = lane1.add_element("start", EventType.START)
Expand Down Expand Up @@ -303,7 +309,9 @@ def test_sample05():
def test_sample06():
with pytest.raises(TooManyConnectionsException):
with ProcessMap(
"Test Max Connection Process", colour_theme="BLUEMOUNTAIN", painter_type="SVG"
"Test Max Connection Process",
colour_theme="BLUEMOUNTAIN",
painter_type="SVG",
) as my_process_map:
with my_process_map.add_lane("Test Lane") as lane1:
start = lane1.add_element("start", EventType.START)
Expand Down Expand Up @@ -343,7 +351,7 @@ def test_sample06():

def test_sample07():
with ProcessMap(
"Product Feature Interface", colour_theme="BLUEMOUNTAIN"
"Product Feature Interface", colour_theme="BLUEMOUNTAIN"
) as my_process_map:
with my_process_map.add_lane("system") as lane_system:
node_start = lane_system.add_element("start", EventType.START)
Expand Down Expand Up @@ -415,7 +423,7 @@ def test_sample07():
g3.connect(node_Update_Figma_Design_, "")

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

with pool_Product_How.add_lane(
"Brokerage Squad"
"Brokerage Squad"
) as lane_Product_How_Brokerage_Squad:
node_Implement_feature_UI = (
lane_Product_How_Brokerage_Squad.add_element(
Expand Down Expand Up @@ -588,7 +596,7 @@ def test_sample10():

def test_sample11():
with ProcessMap(
"Are we living in simulation?", colour_theme="TEALWATERS"
"Are we living in simulation?", colour_theme="TEALWATERS"
) as process_map:
with process_map.add_pool("The World") as pool:
with pool.add_lane("You") as you:
Expand Down
4 changes: 4 additions & 0 deletions src/tests/test_text2diagram.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from processpiper import text2diagram
from util_test import get_test_file_path

Expand Down

0 comments on commit 36ce790

Please sign in to comment.