11import pytest
22
3- from labconnect import db
4- from labconnect .main .opportunity_routes import opportunity_to_dict
5- from labconnect .models import Opportunities
6-
7-
83def test_opportunity_to_dict_none ():
9- assert opportunity_to_dict (None ) == {}
4+ from importlib import import_module
5+ opp_mod = import_module ("labconnect.main.opportunity_routes" )
6+ assert opp_mod .opportunity_to_dict (None ) == {}
107
118
129def test_opportunity_to_dict_populated ():
1310 # create a lightweight Opportunities instance (no DB persistence needed)
14- opp = Opportunities ()
11+ import
12+ class FakeOpp :
13+ pass
14+ opp = FakeOpp ()
1515 opp .id = 123
1616 opp .name = "Unit Test Opportunity"
1717 opp .description = "A test description"
@@ -25,7 +25,9 @@ def test_opportunity_to_dict_populated():
2525 opp .year = 2025
2626 opp .active = True
2727
28- out = opportunity_to_dict (opp )
28+ from importlib import import_module
29+ opp_mod = import_module ("labconnect.main.opportunity_routes" )
30+ out = opp_mod .opportunity_to_dict (opp )
2931
3032 assert out ["id" ] == 123
3133 assert out ["name" ] == "Unit Test Opportunity"
@@ -45,6 +47,9 @@ def test_get_single_opportunity_not_found(test_client):
4547@pytest .mark .usefixtures ("test_client" )
4648def test_get_single_opportunity_success_and_json_variant (test_client ):
4749 # create and persist an opportunity to the test database
50+ from labconnect import db
51+ from labconnect .models import Opportunities
52+
4853 opp = Opportunities ()
4954 opp .name = "Endpoint Test Opportunity"
5055 opp .description = "Endpoint description"
0 commit comments