blob: c94f89cc7af3dd64eca11a351656764e62262147 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
from django_hosts.resolvers import reverse
from .base import APISubdomainTestCase
from ..views import RulesView
class RuleAPITests(APISubdomainTestCase):
def setUp(self):
super().setUp()
self.client.force_authenticate(user=None)
def test_can_access_rules_view(self):
url = reverse('rules', host='api')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json(), list)
def test_link_format_query_param_produces_different_results(self):
url = reverse('rules', host='api')
markdown_links_response = self.client.get(url + '?link_format=md')
html_links_response = self.client.get(url + '?link_format=html')
self.assertNotEqual(
markdown_links_response.json(),
html_links_response.json()
)
def test_format_link_raises_value_error_for_invalid_target(self):
with self.assertRaises(ValueError):
RulesView._format_link("a", "b", "c")
def test_get_returns_400_for_wrong_link_format(self):
url = reverse('rules', host='api')
response = self.client.get(url + '?link_format=unknown')
self.assertEqual(response.status_code, 400)
|