Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

36

from django.test import TestCase 

 

from chapters.forms.admin_forms import ChapterAddForm 

from common.models import Type, Fandom, Fanfic, Chapter 

 

 

class ChapterAddFormTest(TestCase): 

 

def setUp(self): 

self.type = Type.objects.create(name="test_type") 

self.fandom = Fandom.objects.create(name="test_fandom", type=self.type) 

self.fanfic = Fanfic.objects.create(name="Testek fanfic", 

author="michaelRuiz", 

web="http://web-fanfic.com", 

genre1="adv", 

complete=True) 

self.chapter = Chapter.objects.create(title="test chapter", 

num_chapter=1, 

url_chapter="whatever2.com", 

fanfic=self.fanfic) 

 

def test_valid_form(self): 

""" Create chapter form """ 

data = {'title': "Testing test", 'num_chapter': 2, 

'url_chapter': 'whatever.com', 'fanfic': self.fanfic.id} 

form = ChapterAddForm(data=data) 

self.assertTrue(form.is_valid()) 

 

def test_invalid_num_chapter(self): 

""" Create chapter invalid num chapter """ 

data = {'title': "Testing test", 'num_chapter': 1, 

'url_chapter': 'whatever.com', 'fanfic': self.fanfic.id} 

form = ChapterAddForm(data=data) 

self.assertFalse(form.is_valid())