Beispiel #1
0
 def save(self, owner):
     if owner.is_authenticated():
         return List.create_new(
             first_item_text=self.cleaned_data['text'],
             owner=owner)
     else:
         return List.create_new(first_item_text=self.cleaned_data['text'])
Beispiel #2
0
 def test_checks_user_added_to_share_list(self):
     user = User.objects.create(email='*****@*****.**')
     list_ = List.create_new("First item", owner=user)
     response = self.client.post(
             '/lists/%d/share' % (list_.id,),
              data={'email': '*****@*****.**'}
     )
     self.assertIn(user, list_.shared_with.all())
Beispiel #3
0
 def test_create_new_optionally_saves_owner(self):
     user = User.objects.create()
     List.create_new(first_item_text='new item text', owner=user)
     new_list = List.objects.first()
     self.assertEqual(new_list.owner, user)
Beispiel #4
0
 def test_create_new_optionally_saves_owner(self):
     ''' 测试create_new方法可选是否保存所有者 '''
     user = User.objects.create()
     List.create_new(first_item_text="新的待办事项", owner=user)
     new_list = List.objects.first()
     self.assertEqual(new_list.owner, user)
Beispiel #5
0
 def test_create_new_optionally_saves_owner(self) :
     user = User.objects.create()
     List.create_new(first_item_text = 'new item text', owner = user)
     new_list = List.objects.first()
     self.assertEqual(new_list.owner, user)
Beispiel #6
0
 def test_shared_with_add(self):
     user1 = User.objects.create(email='*****@*****.**')
     user2 = User.objects.create(email='*****@*****.**')
     list_ = List.create_new(first_item_text='new item text', owner=user1)
     list_.shared_with.add('*****@*****.**')
     self.assertIn(user2, list_.shared_with.all())
Beispiel #7
0
 def test_create_returns_new_list_object(self):
     list_ = List.create_new(first_item_text='item text')
     self.assertEqual(list_, List.objects.first())
 def test_try_get_object_pk_invalid_pk_returns_none(self):
     ls = List.create_new(first_item_text='whatup')
     ls.save()
     self.assertIsNone(List.try_get_object_pk(pk='4131'))
Beispiel #9
0
 def save(self, owner=None):
     item_text = self.cleaned_data['text']
     if owner:
         return List.create_new(first_item_text=item_text, owner=owner)
     else:
         return List.create_new(first_item_text=item_text)
Beispiel #10
0
 def test_create_returns_new_list_object(self):
     returned = List.create_new(first_item_text='new')
     new_list = List.objects.first()
     assert returned == new_list
 def test_try_get_object_pk_returns_list(self):
     ls = List.create_new(first_item_text='whatup')
     ls.save()
     self.assertEqual(ls, List.try_get_object_pk(pk=str(ls.id)))
Beispiel #12
0
 def test_create_new_creates_list_and_first_item(self):
     List.create_new(first_item_text='new item text')
     new_item = Item.objects.first()
     assert new_item.text == 'new item text'
     new_list = List.objects.first()
     assert new_item.list == new_list
Beispiel #13
0
 def save(self, owner):
     if hasattr(owner, 'email'):
         return List.create_new(first_item_text=self.cleaned_data['text'], owner=owner)
     else:
         return List.create_new(first_item_text=self.cleaned_data['text'])
Beispiel #14
0
 def test_create_returns_new_list_object(self):
     ''' 测试create_new方法创建新列表后返回一个列表对象 '''
     returned = List.create_new(first_item_text="新的待办事项")
     new_list = List.objects.first()
     self.assertEqual(returned, new_list)
Beispiel #15
0
 def test_create_returns_new_list_object(self):
     returned = List.create_new(first_item_text='new item text')
     new_list = List.objects.first()
     self.assertEqual(returned, new_list)
Beispiel #16
0
 def test_create_new_list_and_first_item(self):
     List.create_new(first_item_text='Spiritualism without religion')
     item = Item.objects.first()
     self.assertEqual(item.text, 'Spiritualism without religion')
     list_ = List.objects.first()
     self.assertEqual(item.list, list_)
Beispiel #17
0
 def save(self, owner):
     if owner.is_authenticated:
         return List.create_new(first_item_text=self.cleaned_data['text'],
                                owner=owner)
     else:
         return List.create_new(first_item_text=self.cleaned_data['text'])
Beispiel #18
0
 def test_create_new_optionally_saves_owner(self):
     user = User.objects.create()
     List.create_new(first_item_text='Bruce Brueno', owner=user)
     list_ = List.objects.first()
     self.assertEqual(list_.owner, user)
Beispiel #19
0
 def test_set_list_owner_when_user_is_authenticated(self):
     user = User.objects.create(email="*****@*****.**")
     List.create_new(first_item_text='item 1 text', owner=user)
     new_list = List.objects.first()
     self.assertEqual(new_list.owner, user)
Beispiel #20
0
 def test_create_new_optionally_saves_owner(self):
     '''тест: create_new необязательно сохраняет владельца'''
     user = User.objects.create()
     List.create_new(first_item_text='new item text', owner=user)
     new_list = List.objects.first()
     self.assertEqual(new_list.owner, user)
Beispiel #21
0
 def test_list_name_is_first_item_text(self):
     list_ = List.create_new(first_item_text='new item text')
     self.assertEqual(list_.name, 'new item text')
Beispiel #22
0
 def test_create_returns_new_list_object(self):
     '''тест: create возвращает новый объект списка'''
     returned = List.create_new(first_item_text='new item text')
     new_list = List.objects.first()
     self.assertEqual(returned, new_list)
Beispiel #23
0
 def test_create_new_optionally_saves_owner(self):
     user = User.objects.create(email="*****@*****.**")
     List.create_new(first_item_text="new item text", owner=user)
     self.assertEqual(List.objects.first().owner, user)
Beispiel #24
0
 def test_create_returns_new_list_object(self):
     returned = List.create_new(first_item_text="new item text")
     new_list = List.objects.first()
     self.assertEqual(new_list.get_absolute_url(), returned)
Beispiel #25
0
 def test_create_new_creates_list_and_first_item(self) :
     List.create_new(first_item_text = 'new item text')
     new_item = Item.objects.first()
     self.assertEqual(new_item.text, 'new item text')
     new_list = List.objects.first()
     self.assertEqual(new_item.list, new_list)
Beispiel #26
0
 def test_create_new_creates_list_and_first_item(self):
     List.create_new(first_item_text='new item text')
     new_item = Item.objects.first()
     self.assertEqual(new_item.text, 'new item text')
     new_list = List.objects.first()
     self.assertEqual(new_item.list, new_list)
Beispiel #27
0
 def test_create_returns_new_list_object(self) :
     returned = List.create_new(first_item_text = 'new item text')
     new_list = List.objects.first()
     self.assertEqual(returned, new_list)
Beispiel #28
0
 def test_create_new_creates_new_list_with_first_item(self):
     created_list = List.create_new(first_item_text='New item text')
     self.assertEqual(List.objects.count(), 1)
     self.assertEqual(created_list, List.objects.first())
     self.assertEqual(created_list.item_set.first().text, 'New item text')