-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50390c3
commit 2e23c4e
Showing
7 changed files
with
197 additions
and
14 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,18 @@ | ||
def test_browsable_api(client, db, profile, user): | ||
response = client.get(f"/profiles/{profile.pk}/", HTTP_ACCEPT="text/html,image/png") | ||
|
||
content = response.content.decode("UTF-8") | ||
|
||
assert response.status_code == 200, content | ||
assert "Test API" in content | ||
assert "/api/" in content | ||
assert "HTTP" in content | ||
assert "200" in content | ||
assert "Content-Type" in content | ||
assert "application/json" in content | ||
assert user.username in content | ||
|
||
assert client.get(f"/profiles/{profile.pk}/", HTTP_ACCEPT="").json() | ||
assert client.get(f"/profiles/{profile.pk}/", HTTP_ACCEPT="application/json").json() | ||
assert client.get(f"/profiles/{profile.pk}/", HTTP_ACCEPT="text/plain").json() | ||
assert client.get(f"/profiles/{profile.pk}/?format=json", HTTP_ACCEPT="text/html").json() |
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,3 @@ | ||
{% extends "worf/base.html" %} | ||
|
||
{# Override this template in your own templates directory to customize #} |
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,79 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
{% block head %} | ||
{% block meta %} | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
<meta name="robots" content="none,noarchive"/> | ||
{% endblock %} | ||
|
||
<title>{{ api_name }}: {{ request.get_full_path }}</title> | ||
|
||
{% block style %} | ||
<link href="https://unpkg.com/[email protected]/dist/tailwind.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" rel="stylesheet"> | ||
<link href="https://unpkg.com/[email protected]/themes/prism-atom-dark.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" rel="stylesheet"> | ||
<link href="https://unpkg.com/[email protected]/prism-js-fold.css" crossorigin="anonymous" referrerpolicy="no-referrer" rel="stylesheet"> | ||
<style> | ||
body { background: #131417; color: white; } | ||
a { color: #58A6FF; } | ||
a:hover { text-decoration: underline; } | ||
nav, pre { background: #202126 !important; } | ||
strong { font-weight: 500; } | ||
pre[class*="language-"], :not(pre) > code[class*="language-"] { border-radius: 0; } | ||
.token a { color: #58A6FF; } | ||
.token.boolean { color: #FBBF24; } | ||
.token.property { color: white; } | ||
.token.string { color: #69F5AB; white-space: normal; word-break: break-all; } | ||
</style> | ||
{% endblock %} | ||
{% endblock %} | ||
</head> | ||
|
||
<body> | ||
{% block body %} | ||
{% block nav %} | ||
<nav class="p-4"> | ||
<div class="max-w-5xl mx-auto"> | ||
{% block branding %} | ||
<a href="{{ api_root }}" class="font-medium text-lg text-white" rel="nofollow"> | ||
{{ api_name }} | ||
</a> | ||
{% endblock %} | ||
</div> | ||
</nav> | ||
{% endblock %} | ||
|
||
<div class="max-w-5xl mx-auto"> | ||
<main> | ||
{% block content %} | ||
<nav class="font-mono break-all my-4 px-4 py-2"> | ||
<strong>{{ request.method }}</strong> {{ request.get_full_path }} | ||
</nav> | ||
|
||
<div class="my-4"> | ||
<pre class="w-full p-4 overflow-auto"><strong>HTTP {{ response.status_code }} {{ response.status_text }}</strong>{% for key, value in response.headers.items %} | ||
<strong>{{ key }}:</strong> {{ value }}{% endfor %} | ||
|
||
<code class="language-json">{{ content }}</code></pre> | ||
</div> | ||
{% endblock content %} | ||
</main> | ||
</div> | ||
|
||
{% block script %} | ||
<script src="https://unpkg.com/[email protected]" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
<script src="https://unpkg.com/[email protected]/components/prism-json.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
<script src="https://unpkg.com/[email protected]/plugins/keep-markup/prism-keep-markup.js"></script> | ||
<script src="https://unpkg.com/[email protected]/plugins/autolinker/prism-autolinker.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
<script src="https://unpkg.com/[email protected]" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
<script> | ||
Prism.hooks.add("complete", () => { | ||
for (const details of document.getElementsByTagName("details")) { | ||
details.open = true | ||
} | ||
}) | ||
</script> | ||
{% endblock %} | ||
{% endblock %} | ||
</body> | ||
</html> |
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