-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
and clean up mock usage in other tests
- Loading branch information
Showing
8 changed files
with
89 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.views import View | ||
|
||
|
||
class KanalenView(View): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from django.core.management import call_command | ||
from django.utils.translation import gettext as _ | ||
|
||
import pytest | ||
import requests_mock | ||
|
||
from .conftest import NOTIFICATIONS_API_ROOT | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_register_kanalen(notifications_config): | ||
with requests_mock.Mocker() as m: | ||
m.get(f"{NOTIFICATIONS_API_ROOT}kanaal?naam=personen", json=[]) | ||
m.post(f"{NOTIFICATIONS_API_ROOT}kanaal") | ||
call_command("register_kanalen") | ||
|
||
assert len(m.request_history) == 2 | ||
|
||
get_request = m.request_history[0] | ||
assert get_request.url == f"{NOTIFICATIONS_API_ROOT}kanaal?naam=personen" | ||
|
||
post_request = m.request_history[1] | ||
assert post_request.url == f"{NOTIFICATIONS_API_ROOT}kanaal" | ||
assert post_request.json() == { | ||
"naam": "personen", | ||
"documentatieLink": "https://example.com/notificaties/kanalen/#personen", | ||
"filters": ["address_street"], | ||
} | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_register_kanalen_already_exists(notifications_config): | ||
with requests_mock.Mocker() as m: | ||
m.get( | ||
f"{NOTIFICATIONS_API_ROOT}kanaal?naam=personen", | ||
json=[ | ||
{ | ||
"naam": "personen", | ||
"documentatieLink": "https://example.com/notificaties/kanalen/#personen", | ||
"filters": ["address_street"], | ||
} | ||
], | ||
) | ||
m.post(f"{NOTIFICATIONS_API_ROOT}kanaal") | ||
call_command("register_kanalen") | ||
|
||
assert len(m.request_history) == 1 | ||
|
||
get_request = m.request_history[0] | ||
assert get_request.url == f"{NOTIFICATIONS_API_ROOT}kanaal?naam=personen" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters