This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 127
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
FoxMaSk
committed
Nov 9, 2017
1 parent
e5ef932
commit 098fadb
Showing
6 changed files
with
35 additions
and
47 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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
# coding: utf-8 | ||
from django.core.urlresolvers import reverse | ||
from django.contrib.auth.models import User | ||
from django.test import RequestFactory | ||
|
||
from django_th.models import UserService | ||
|
||
from django_th.forms.base import UserServiceForm | ||
from django_th.models import UserService, ServicesActivated | ||
from django_th.tests.test_main import MainTest, setup_view | ||
from django_th.views_userservices import UserServiceListView, UserServiceCreateView, UserServiceUpdateView | ||
|
||
|
@@ -36,6 +39,14 @@ def test_context_data(self): | |
|
||
class UserServiceCreateViewTestCase(MainTest): | ||
|
||
def setUp(self): | ||
try: | ||
self.user = User.objects.get(username='john') | ||
except User.DoesNotExist: | ||
self.user = User.objects.create_user( | ||
username='john', email='[email protected]', password='doe') | ||
ServicesActivated.objects.create(name='ServiceRss', status=True, auth_required=False, description='Service RSS') | ||
|
||
def test_get(self): | ||
template_name = 'services/service_form.html' | ||
# Setup request and view. | ||
|
@@ -48,6 +59,16 @@ def test_get(self): | |
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response.template_name[0], template_name) | ||
|
||
def test_valid_form(self): | ||
data = {'duration': 'n'} | ||
form = UserServiceForm(data=data, initial={'user': self.user, 'name': 'ServiceRss'}) | ||
self.assertTrue(form.is_valid()) | ||
|
||
def test_invalid_form(self): | ||
data = {'duration': 'x'} | ||
form = UserServiceForm(data=data, initial={'user': self.user, 'name': 'ServiceRss'}) | ||
self.assertFalse(form.is_valid()) | ||
|
||
|
||
class UserServiceUpdateViewTestCase(MainTest): | ||
|
||
|
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