Пример #1
0
    def test_should_create_task_with_default_priority(self):
        # Arrange
        author = UserFactory.create()
        owner = UserFactory.create()
        tasks_manager = Mock(Task.objects)
        form = RestrictedAddTaskForm(
            self._data, author=author, owner=owner,
            tasks_manager=tasks_manager)
        author_tasks = tasks_manager.get_for_owner_by_author.return_value
        author_tasks.count.return_value = 2

        # Act
        form.is_valid()
        obj = form.save()

        # Assert
        self.assertIsNotNone(obj.pk)
        self.assertEqual(obj.title, self._title)
        self.assertEqual(obj.priority, 4)
        self.assertEqual(obj.author, author)
        self.assertEqual(obj.owner, owner)
Пример #2
0
    def test_should_create_task_with_default_priority(self):
        # Arrange
        author = UserFactory.create()
        owner = UserFactory.create()
        tasks_manager = Mock(Task.objects)
        form = RestrictedAddTaskForm(self._data,
                                     author=author,
                                     owner=owner,
                                     tasks_manager=tasks_manager)
        author_tasks = tasks_manager.get_for_owner_by_author.return_value
        author_tasks.count.return_value = 2

        # Act
        form.is_valid()
        obj = form.save()

        # Assert
        self.assertIsNotNone(obj.pk)
        self.assertEqual(obj.title, self._title)
        self.assertEqual(obj.priority, 4)
        self.assertEqual(obj.author, author)
        self.assertEqual(obj.owner, owner)