-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/localcontexts/localconte…
…xtshub into 10-4-develop-to-subscriptions-update
- Loading branch information
Showing
21 changed files
with
728 additions
and
49 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
Empty file.
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,33 @@ | ||
import os | ||
from urllib.parse import urlparse | ||
from urllib.parse import urljoin | ||
|
||
from django import template | ||
|
||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def external_api(external_url: str) -> str: | ||
""" | ||
Tag converts an external_url into an internal_url | ||
so the response can be mocked with a fixture. | ||
Args: | ||
external_url: Url to an external API resource. | ||
Returns: | ||
When TEST_LIVE_SERVER_DOMAIN is available, the url is transformed so | ||
the external domain is swapped with the TEST_LIVE_SERVER_DOMAIN. | ||
""" | ||
test_live_server_domain = os.environ.get('TEST_LIVE_SERVER_DOMAIN') | ||
if not test_live_server_domain: | ||
return external_url | ||
url_components = urlparse(external_url) | ||
|
||
try: | ||
# return the internal_url formed by the domain and url_components.path | ||
return urljoin(test_live_server_domain, url_components.path) | ||
except Exception: | ||
return external_url |
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
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
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,14 @@ | ||
from localcontexts.urls import urlpatterns | ||
from django.urls import path | ||
|
||
from . views import ( | ||
native_land_map_list, | ||
native_land_boundary_response | ||
) | ||
|
||
|
||
class UrlsWithMockedExternalApi: | ||
urlpatterns = urlpatterns + [ | ||
path('wp-json/nativeland/v1/map-list/', native_land_map_list), | ||
path('wp-json/nativeland/v1/api/index.php', native_land_boundary_response) | ||
] |
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,23 @@ | ||
import json | ||
|
||
from django.http import JsonResponse | ||
|
||
|
||
def native_land_map_list(request): | ||
""" | ||
This view is called when populating the dropdown | ||
of Native Land territories | ||
""" | ||
json_data = open('tests/fixtures/native_land_map_list.json') | ||
data = json.load(json_data) | ||
return JsonResponse(data, safe=False) | ||
|
||
|
||
def native_land_boundary_response(request): | ||
""" | ||
This view is called when getting specific boundary data | ||
for a single Native Land territory | ||
""" | ||
json_data = open('tests/fixtures/native_land_boundary_response.json') | ||
data = json.load(json_data) | ||
return JsonResponse(data, safe=False) |
Oops, something went wrong.