Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianemoyano committed Dec 30, 2021
1 parent 54c5407 commit f5bac54
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from unittest import mock

from django.test.client import Client
from django.urls import reverse
from unittest.mock import MagicMock, patch

from watchman import settings as watchman_settings
from watchman.decorators import check
Expand All @@ -38,6 +38,17 @@ def test_200_ok_if_matching_first_token_in_list(self):
response = self.client.get(reverse("status"), data)
self.assertEqual(response.status_code, 200)

@patch('django.db.connections')
def test_cursor_is_called(self, mock_connections):
cursor_mock = MagicMock()
mock_connections['default'].cursor().__enter__.return_value = cursor_mock
data = {
'watchman-token': 't1',
}
self.client.get(reverse('status'), data)
cursor_mock.execute.assert_called_once_with('SELECT 1')


def test_200_ok_if_matching_second_token_in_list(self):
data = {
"watchman-token": "t2",
Expand Down

0 comments on commit f5bac54

Please sign in to comment.