Skip to content

Commit

Permalink
💚 Use AssertTimelineLogMixin to fix KVK logging test
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Feb 16, 2024
1 parent beb6641 commit 4b4e5df
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/open_inwoner/kvk/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from open_inwoner.accounts.tests.factories import UserFactory
from open_inwoner.utils.logentry import LOG_ACTIONS
from open_inwoner.utils.test import ClearCachesMixin
from open_inwoner.utils.tests.helpers import AssertTimelineLogMixin

from ..client import KvKClient
from ..models import KvKConfig
Expand Down Expand Up @@ -104,7 +105,7 @@ def test_user_is_not_updated_when_http_500(self, m):
self.assertFalse(user.is_prepopulated)


class TestLogging(TestCase):
class TestLogging(AssertTimelineLogMixin, TestCase):
@classmethod
def setUpTestData(cls):
config = KvKConfig(
Expand Down Expand Up @@ -132,20 +133,11 @@ def test_signal_updates_logging(self, m):

self.client.force_login(user=user)

log_entry = TimelineLog.objects.filter(object_id=user.id)[2]

self.assertEquals(
log_entry.timestamp.strftime("%m/%d/%Y, %H:%M:%S"), "10/18/2021, 13:00:00"
)
self.assertEquals(log_entry.object_id, str(user.id))
self.assertEquals(
log_entry.extra_data,
{
"message": _("data was retrieved from KvK API"),
"log_level": logging.INFO,
"action_flag": list(LOG_ACTIONS[5]),
"content_object_repr": str(user),
},
self.assertTimelineLog(
_("data was retrieved from KvK API"),
level=logging.INFO,
action_flag=list(LOG_ACTIONS[5]),
content_object_repr=str(user),
)

@requests_mock.Mocker()
Expand Down

0 comments on commit 4b4e5df

Please sign in to comment.