-
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.
👌 [#28] add unittests for is_local function
- Loading branch information
1 parent
4d4063f
commit 11e73b0
Showing
1 changed file
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
Test django_loose_fk.utils.is_local function with various | ||
combinations of settings | ||
""" | ||
|
||
from django.test import override_settings | ||
|
||
from django_loose_fk.utils import is_local | ||
|
||
|
||
@override_settings( | ||
LOOSE_FK_LOCAL_BASE_URLS=["http://api.example.nl/ozgv-t/zaken"], | ||
) | ||
def test_with_setting_same_host_same_prefix(): | ||
assert ( | ||
is_local(host="api.example.nl", url="http://api.example.nl/ozgv-t/zaken/1") | ||
is True | ||
) | ||
|
||
|
||
@override_settings( | ||
LOOSE_FK_LOCAL_BASE_URLS=["http://api.example.nl/ozgv-t/zaken"], | ||
) | ||
def test_with_setting_same_host_diff_prefix(): | ||
assert ( | ||
is_local(host="api.example.nl", url="http://api.example.nl/ozgv-t/documenten/1") | ||
is False | ||
) | ||
|
||
|
||
@override_settings( | ||
LOOSE_FK_LOCAL_BASE_URLS=["http://otherapi.example.nl/ozgv-t/zaken"], | ||
) | ||
def test_with_setting_diff_host(): | ||
assert ( | ||
is_local(host="api.example.nl", url="http://otherapi.example.nl/ozgv-t/zaken/1") | ||
is True | ||
) | ||
|
||
|
||
def test_no_setting_same_host_with_prefix(): | ||
assert ( | ||
is_local(host="api.example.nl", url="http://api.example.nl/ozgv-t/zaken/1") | ||
is True | ||
) | ||
|
||
|
||
def test_no_setting_same_host_no_prefix(): | ||
assert is_local(host="api.example.nl", url="http://api.example.nl/zaken/1") is True | ||
|
||
|
||
def test_no_setting_diff_host(): | ||
assert ( | ||
is_local(host="api.example.nl", url="http://otherapi.example.nl/ozgv-t/zaken/1") | ||
is False | ||
) |