File tree 5 files changed +53
-48
lines changed
example_project/polls/fixtures
5 files changed +53
-48
lines changed Original file line number Diff line number Diff line change
1
+ from django .contrib .auth import get_user_model
2
+
3
+ import factory
4
+
5
+
6
+ class UserFactory (factory .DjangoModelFactory ):
7
+ FACTORY_FOR = get_user_model ()
8
+ first_name = factory .Sequence (lambda i : u'John{}' .format (i ))
9
+ last_name = factory .Sequence (lambda i : u'Doe{}' .format (i ))
10
+ username = factory .LazyAttribute (lambda x : '{}{}' .format (
11
+ x .first_name , x .last_name ))
12
+ email = factory .LazyAttribute (lambda x : '{}@{}.com' .format (
13
+ x .first_name .lower (), x .last_name .lower ()))
14
+ password = factory .PostGenerationMethodCall ('set_password' , 'password' )
15
+
16
+
Original file line number Diff line number Diff line change @@ -67,8 +67,9 @@ def test_get_djoa_button_attrs_custom_attrs_get_partitioned(self):
67
67
68
68
69
69
class QuerySetIshTest (TestCase ):
70
+ fixtures = ['sample_data' ]
71
+
70
72
def setUp (self ):
71
- # as defined in initial_data fixture
72
73
# WISHLIST don't depend on fixture
73
74
self .obj = Poll .objects .get (pk = 1 )
74
75
@@ -102,8 +103,9 @@ def test_queryset_supports_update(self):
102
103
103
104
104
105
class DecoratorTest (TestCase ):
106
+ fixtures = ['sample_data' ]
107
+
105
108
def setUp (self ):
106
- # as defined in initial_data fixture
107
109
# WISHLIST don't depend on fixture
108
110
self .obj = Poll .objects .get (pk = 1 )
109
111
self .queryset = Poll .objects .all ()
Original file line number Diff line number Diff line change 1
1
from django .test import TestCase
2
2
3
3
from example_project .polls .models import Choice
4
+ from ..factories import UserFactory
4
5
5
6
6
7
class LoggedInTestCase (TestCase ):
7
8
def setUp (self ):
8
9
super (LoggedInTestCase , self ).setUp ()
10
+ UserFactory .create (
11
+ is_staff = True , username = 'admin' , password = 'password' )
9
12
self .client .login (username = 'admin' , password = 'admin' )
10
13
11
14
12
15
class AppTests (LoggedInTestCase ):
16
+ fixtures = ['sample_data' ]
17
+
13
18
def test_bare_mixin_works (self ):
14
19
# hit admin that doesn't have any tools defined, just the mixin
15
20
response = self .client .get ('/admin/polls/poll/add/' )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "pk" : 1 ,
4
+ "model" : " polls.poll" ,
5
+ "fields" : {
6
+ "pub_date" : " 2012-10-20T18:20:35Z" ,
7
+ "question" : " Do you like me?"
8
+ }
9
+ },
10
+ {
11
+ "pk" : 1 ,
12
+ "model" : " polls.choice" ,
13
+ "fields" : {
14
+ "choice_text" : " Yes" ,
15
+ "poll" : 1 ,
16
+ "votes" : 0
17
+ }
18
+ },
19
+ {
20
+ "pk" : 2 ,
21
+ "model" : " polls.choice" ,
22
+ "fields" : {
23
+ "choice_text" : " No" ,
24
+ "poll" : 1 ,
25
+ "votes" : 100
26
+ }
27
+ }
28
+ ]
You can’t perform that action at this time.
0 commit comments