wulkanowy-web/tests/test_views.py

43 lines
1.2 KiB
Python
Raw Normal View History

2021-01-23 12:23:24 +01:00
from django.test import TestCase, Client
from django.urls import reverse
import json
class TestViews(TestCase):
def setUp(self):
self.client = Client()
2021-01-26 12:22:24 +01:00
self.csrf_token = Client(enforce_csrf_checks=True)
2021-01-23 12:23:24 +01:00
self.list_url = reverse('home')
self.detail_url = reverse('content')
def test_views(self):
#DEFAULT_VIEW
response = self.client.get(self.list_url)
self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'frontend/index.html')
#CONTENT_VIEW
response = self.client.get(self.detail_url)
2021-01-26 12:22:24 +01:00
self.assertEquals(response.status_code, 302)
#ACCOUNT_MANAGER
response = self.client.get(reverse('account_manager'))
self.assertEquals(response.status_code, 302)
#API
data = {
"loginName": "jan@fakelog.cf",
"Password": "jan123",
"Symbol": "powiatwulkanowy",
"diaryUrl": "http://cufs.fakelog.cf/"
}
response = self.client.post(reverse('login'), content_type='application/xml', data=json.dumps(data))
self.assertEquals(response.status_code, 200)
#JAN
#JOANNA