Skip to content

test(general): Add some missing code coverage #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/functional/test_lambda_trigger_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def message(self) -> str:

assert DataClassSample(data1) == DataClassSample(data1)
assert DataClassSample(data1) != DataClassSample(data2)
# Comparing against a dict should not be equals
assert DataClassSample(data1) != data1
assert data1 != DataClassSample(data1)
assert DataClassSample(data1) is not data1
assert data1 is not DataClassSample(data1)

Expand Down
12 changes: 12 additions & 0 deletions tests/functional/test_tracing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import contextlib
import sys
from unittest.mock import Mock

import pytest

Expand Down Expand Up @@ -212,3 +214,13 @@ def handler(event, context):
result = handler({}, {})
assert "testresult" in result
assert "testresult2" in result


def test_aiohttp_trace_config():
aiohttp_mock = Mock()
sys.modules["aiohttp"] = aiohttp_mock
from aws_lambda_powertools.tracing import aiohttp_trace_config

trace_config: Mock = aiohttp_trace_config()

assert trace_config._extract_mock_name() == "mock.TraceConfig()"
26 changes: 26 additions & 0 deletions tests/functional/test_utilities_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,32 @@ def _get_multiple(self, path: str, **kwargs) -> Dict[str, str]:
assert str_value == json.dumps(mock_body_json)


def test_appconf_get_app_config_new(monkeypatch, mock_name, mock_value):
# GIVEN
class TestProvider(BaseProvider):
def __init__(self, environment: str, application: str):
super().__init__()

def get(self, name: str, **kwargs) -> str:
return mock_value

def _get(self, name: str, **kwargs) -> str:
raise NotImplementedError()

def _get_multiple(self, path: str, **kwargs) -> Dict[str, str]:
raise NotImplementedError()

monkeypatch.setattr(parameters.appconfig, "DEFAULT_PROVIDERS", {})
monkeypatch.setattr(parameters.appconfig, "AppConfigProvider", TestProvider)

# WHEN
value = parameters.get_app_config(mock_name, environment="dev", application="myapp")

# THEN
assert parameters.appconfig.DEFAULT_PROVIDERS["appconfig"] is not None
assert value == mock_value


def test_transform_value_json(mock_value):
"""
Test transform_value() with a json transform
Expand Down