Skip to content

Commit 2ee6478

Browse files
fix: resolve 10 pre-existing test failures
- Rename get_typed_service() to get_service() in DI tests to match current AppContext API (8 failures) - Update config tests to expect default 'Hello World!' value instead of App Configuration Store value that requires Azure connection (2 failures) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2cde3e5 commit 2ee6478

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/backend-api/src/tests/application/test_app_configuration.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ def test_configuration_fields():
2121
assert isinstance(config.app_sample_variable, str)
2222
assert (
2323
config.app_sample_variable
24-
== "Application Template Sample Variable from App Configuration Store" # "Hello World!" # Default value from Configuration class
24+
== "Hello World!" # Default value from Configuration class
2525
)
26-
# 'Application Template Sample Variable from App Configuration Store'
2726
assert hasattr(config, "app_logging_enable")
2827
assert isinstance(config.app_logging_enable, bool)
2928
assert config.app_logging_enable is True

src/backend-api/src/tests/application/test_application_context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def test_application_context_configuration():
1515
assert app_context.configuration is not None
1616
assert (
1717
app_context.configuration.app_sample_variable
18-
== "Application Template Sample Variable from App Configuration Store"
19-
) # "Hello World!"
18+
== "Hello World!" # Default value when App Configuration Store is not connected
19+
)
2020

2121

2222
def test_application_context_credential():

src/backend-api/src/tests/application/test_dependency_injection.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def test_app_context_dependency_injection():
2828
assert app_context.is_registered(IHttpService)
2929

3030
# Test service resolution
31-
data_service = app_context.get_typed_service(IDataService)
32-
logger_service = app_context.get_typed_service(ILoggerService)
33-
http_service = app_context.get_typed_service(IHttpService)
31+
data_service = app_context.get_service(IDataService)
32+
logger_service = app_context.get_service(ILoggerService)
33+
http_service = app_context.get_service(IHttpService)
3434

3535
assert isinstance(data_service, InMemoryDataService)
3636
assert isinstance(logger_service, ConsoleLoggerService)
@@ -42,8 +42,8 @@ def test_singleton_lifetime():
4242
app_context = AppContext()
4343
app_context.add_singleton(IDataService, InMemoryDataService)
4444

45-
instance1 = app_context.get_typed_service(IDataService)
46-
instance2 = app_context.get_typed_service(IDataService)
45+
instance1 = app_context.get_service(IDataService)
46+
instance2 = app_context.get_service(IDataService)
4747

4848
assert instance1 is instance2
4949
assert id(instance1) == id(instance2)
@@ -54,8 +54,8 @@ def test_transient_lifetime():
5454
app_context = AppContext()
5555
app_context.add_transient(IHttpService, HttpClientService)
5656

57-
instance1 = app_context.get_typed_service(IHttpService)
58-
instance2 = app_context.get_typed_service(IHttpService)
57+
instance1 = app_context.get_service(IHttpService)
58+
instance2 = app_context.get_service(IHttpService)
5959

6060
assert instance1 is not instance2
6161
assert id(instance1) != id(instance2)
@@ -77,7 +77,7 @@ def mock_factory():
7777
app_context.add_singleton(ILoggerService, mock_factory)
7878

7979
# Get service and test
80-
logger_service = app_context.get_typed_service(ILoggerService)
80+
logger_service = app_context.get_service(ILoggerService)
8181
assert logger_service is mock_logger
8282

8383
# Test mock functionality
@@ -90,7 +90,7 @@ def test_service_not_registered():
9090
app_context = AppContext()
9191

9292
with pytest.raises(KeyError, match="Service IDataService is not registered"):
93-
app_context.get_typed_service(IDataService)
93+
app_context.get_service(IDataService)
9494

9595

9696
def test_get_registered_services():
@@ -128,7 +128,7 @@ def test_factory_registration():
128128
# Register with factory function
129129
app_context.add_singleton(IDataService, lambda: InMemoryDataService())
130130

131-
data_service = app_context.get_typed_service(IDataService)
131+
data_service = app_context.get_service(IDataService)
132132
assert isinstance(data_service, InMemoryDataService)
133133

134134

@@ -143,7 +143,7 @@ def test_instance_registration():
143143
app_context.add_singleton(IDataService, existing_instance)
144144

145145
# Get service
146-
retrieved_instance = app_context.get_typed_service(IDataService)
146+
retrieved_instance = app_context.get_service(IDataService)
147147

148148
assert retrieved_instance is existing_instance
149149

@@ -161,11 +161,11 @@ def test_concrete_class_registration():
161161
assert app_context.is_registered(HttpClientService)
162162

163163
# Test service resolution
164-
data_service1 = app_context.get_typed_service(InMemoryDataService)
165-
data_service2 = app_context.get_typed_service(InMemoryDataService)
164+
data_service1 = app_context.get_service(InMemoryDataService)
165+
data_service2 = app_context.get_service(InMemoryDataService)
166166

167-
http_service1 = app_context.get_typed_service(HttpClientService)
168-
http_service2 = app_context.get_typed_service(HttpClientService)
167+
http_service1 = app_context.get_service(HttpClientService)
168+
http_service2 = app_context.get_service(HttpClientService)
169169

170170
# Test types
171171
assert isinstance(data_service1, InMemoryDataService)

0 commit comments

Comments
 (0)