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

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

from django.test import TestCase 

from users.models import CustomUser 

from main.models import Fanfic 

from django.test.client import Client 

 

 

class FanficTests(TestCase): 

 

def setUp(self): 

self.normal_user = CustomUser.objects.create( 

name_surname="name", 

country="AM", 

date_of_birth="2000-07-02", 

email="em@gm.com", 

username='testuser', 

password="12345") 

 

self.one_fanfic = Fanfic.objects.create( 

name="Testek1 fanfic", 

author="michaelRuiz", 

web="http://webfanfic.com/jkas", 

genre1="adv", 

status="c") 

 

self.two_fanfic = Fanfic.objects.create( 

name="Testek2 fanfic", 

author="michaelRuiz", 

web="www.web2fanfic.org/sldkf", 

genre1="adv", 

status="c") 

 

self.three_fanfic = Fanfic.objects.create( 

name="Testek3 fanfic", 

author="michaelRuiz", 

web="https://www.web3fanfic.com/slkdf", 

genre1="adv", 

status="c") 

 

self.client = Client() 

self.client.force_login(user=self.normal_user) 

 

def test_str(self): 

''' Test if name is well set ''' 

self.assertEquals(self.one_fanfic.name, "Testek1 fanfic") 

 

def test_get_domain(self): 

''' Test if the domain is well obtained ''' 

self.assertEquals(self.one_fanfic.get_domain(), "webfanfic") 

self.assertEquals(self.two_fanfic.get_domain(), "web2fanfic") 

self.assertEquals(self.three_fanfic.get_domain(), "web3fanfic") 

 

def test_similar_by_title_and_author(self): 

''' Test if you get similar fanfics by title and author correctly ''' 

similar_ones = Fanfic.get_similar_by_title_and_author( 

"Test", "michael") 

self.assertEquals(similar_ones.count(), 3)