def test_review_number_attribute_is_a_read_only_attribute(self): """testing if the review_number attribute is a read only attribute """ review = Review(**self.kwargs) with pytest.raises(AttributeError) as cm: review.review_number = 2 assert str(cm.value) == "can't set attribute"
def test_reviewer_attribute_is_working_properly(self): """testing if the reviewer attribute is working properly """ self.task1.responsible = [self.user1, self.user2] self.kwargs['reviewer'] = self.user1 review = Review(**self.kwargs) review.reviewer = self.user2 assert review.reviewer == self.user2
def test_review_number_attribute_is_a_read_only_attribute(self): """testing if the review_number attribute is a read only attribute """ review = Review(**self.kwargs) with self.assertRaises(AttributeError) as cm: review.review_number = 2 self.assertEqual(str(cm.exception), "can't set attribute")
def test_reviewer_attribute_is_not_in_Task_responsible_list(self): """testing if it is possible to use some other user which is not in the Task.responsible list as the reviewer """ self.task1.responsible = [self.user1] self.kwargs['reviewer'] = self.user1 review = Review(**self.kwargs) review.reviewer = self.user2 self.assertEqual(review.reviewer, self.user2)
def test_approve_method_updates_task_status_correctly_for_a_single_responsible_task(self): """testing if the Review.approve() method will update the task status correctly for a task with only one responsible """ self.task1.responsible = [self.user1] self.kwargs['reviewer'] = self.user1 assert self.task1.status != self.status_cmpl review = Review(**self.kwargs) review.approve() assert self.task1.status == self.status_cmpl
def test_reviewer_attribute_is_set_to_None(self): """testing if a TypeError will be raised when the reviewer attribute is set to None """ review = Review(**self.kwargs) with pytest.raises(TypeError) as cm: review.reviewer = None assert str(cm.value) == \ 'Review.reviewer should be set to a stalker.models.auth.User ' \ 'instance, not NoneType'
def test_reviewer_attribute_is_working_properly(self): """testing if the reviewer attribute is working properly """ self.task1.responsible = [self.user1, self.user2] self.kwargs['reviewer'] = self.user1 review = Review(**self.kwargs) review.reviewer = self.user2 self.assertEqual( self.user2, review.reviewer )
def test_reviewer_attribute_is_not_a_User_instance(self): """testing if a TypeError will be raised when the reviewer attribute is set to a value other than a User instance """ review = Review(**self.kwargs) with pytest.raises(TypeError) as cm: review.reviewer = 'not a user' assert str(cm.value) == \ 'Review.reviewer should be set to a stalker.models.auth.User ' \ 'instance, not str'
def test_reviewer_attribute_is_not_a_User_instance(self): """testing if a TypeError will be raised when the reviewer attribute is set to a value other than a User instance """ review = Review(**self.kwargs) with self.assertRaises(TypeError) as cm: review.reviewer = 'not a user' self.assertEqual( str(cm.exception), 'Review.reviewer should be set to a stalker.models.auth.User ' 'instance, not str')
def test_reviewer_attribute_is_set_to_None(self): """testing if a TypeError will be raised when the reviewer attribute is set to None """ review = Review(**self.kwargs) with self.assertRaises(TypeError) as cm: review.reviewer = None self.assertEqual( str(cm.exception), 'Review.reviewer should be set to a stalker.models.auth.User ' 'instance, not NoneType')
def test_review_number_attribute_is_initialized_to_the_task_review_number_plus_1( self): """testing if the review_number attribute is initialized with task.review_number + 1 """ review = Review(**self.kwargs) assert review.review_number == 1
def test_approve_method_updates_task_status_correctly_for_a_single_responsible_task(self): """testing if the Review.approve() method will update the task status correctly for a task with only one responsible """ self.task1.responsible = [self.user1] self.kwargs['reviewer'] = self.user1 self.assertNotEqual( self.status_cmpl, self.task1.status ) review = Review(**self.kwargs) review.approve() self.assertEqual( self.status_cmpl, self.task1.status )
def test_review_number_attribute_is_a_read_only_attribute(self): """testing if the review_number attribute is a read only attribute """ review = Review(**self.kwargs) self.assertRaises( AttributeError, setattr, review, 'review_number', 2 )
def test_reviewer_argument_is_working_properly(self): """testing if the reviewer argument value is correctly passed to reviewer attribute """ self.task1.responsible = [self.user1] self.kwargs['reviewer'] = self.user1 review = Review(**self.kwargs) assert review.reviewer == self.user1
def test_reviewer_argument_is_not_in_Task_responsible_list(self): """testing if it is possible to use some other user which is not in the Task.responsible list as the reviewer """ self.task1.responsible = [self.user1] self.kwargs['reviewer'] = self.user2 review = Review(**self.kwargs) assert review.reviewer == self.user2
def test_task_argument_is_not_a_Task_instance(self): """testing if a TypeError will be raised when the task argument value is not a Task instance """ self.kwargs['task'] = 'not a Task instance' with pytest.raises(TypeError) as cm: Review(**self.kwargs) assert str(cm.value) == \ 'Review.task should be an instance of stalker.models.task.Task, ' \ 'not str'
def test_reviewer_argument_is_skipped(self): """testing if a TypeError will be raised when the reviewer argument is skipped """ self.kwargs.pop('reviewer') with pytest.raises(TypeError) as cm: Review(**self.kwargs) assert str(cm.value) == \ 'Review.reviewer should be set to a stalker.models.auth.User ' \ 'instance, not NoneType'
def test_reviewer_argument_is_not_a_User_instance(self): """testing if a TypeError will be raised when the reviewer argument is not a User instance """ self.kwargs['reviewer'] = 'not a user instance' with pytest.raises(TypeError) as cm: Review(**self.kwargs) assert str(cm.value) == \ 'Review.reviewer should be set to a stalker.models.auth.User ' \ 'instance, not str'
def test_task_argument_is_not_a_Task_instance(self): """testing if a TypeError will be raised when the task argument value is not a Task instance """ self.kwargs['task'] = 'not a Task instance' with self.assertRaises(TypeError) as cm: Review(**self.kwargs) self.assertEqual( str(cm.exception), 'Review.task should be an instance of stalker.models.task.Task, ' 'not str')
def test_reviewer_argument_is_skipped(self): """testing if a TypeError will be raised when the reviewer argument is skipped """ self.kwargs.pop('reviewer') with self.assertRaises(TypeError) as cm: Review(**self.kwargs) self.assertEqual( str(cm.exception), 'Review.reviewer should be set to a stalker.models.auth.User ' 'instance, not NoneType')
def test_reviewer_argument_is_not_a_User_instance(self): """testing if a TypeError will be raised when the reviewer argument is not a User instance """ self.kwargs['reviewer'] = 'not a user instance' with self.assertRaises(TypeError) as cm: Review(**self.kwargs) self.assertEqual( str(cm.exception), 'Review.reviewer should be set to a stalker.models.auth.User ' 'instance, not str')
def test_task_argument_is_not_a_leaf_task(self): """testing if a ValueError will be raised when the task given in task argument is not a leaf task """ from stalker import Task task1 = Task(name='Task1', project=self.project) task2 = Task(name='Task2', parent=task1) self.kwargs['task'] = task1 with pytest.raises(ValueError) as cm: Review(**self.kwargs) assert str(cm.value) == \ 'It is only possible to create a review for a leaf tasks, and ' \ '<Task1 (Task)> is not a leaf task.'
def test_reviewer_attribute_is_not_a_User_instance(self): """testing if a TypeError will be raised when the reviewer attribute is set to a value other than a User instance """ review = Review(**self.kwargs) self.assertRaises(TypeError, setattr, review, 'reviewer', 'not a user')
def test_reviewer_attribute_is_set_to_None(self): """testing if a TypeError will be raised when the reviewer attribute is set to None """ review = Review(**self.kwargs) self.assertRaises(TypeError, setattr, review, 'reviewer', None)
def test_status_is_new_for_a_newly_created_review_instance(self): """testing if the status is NEW for a newly created review instance """ review = Review(**self.kwargs) self.assertEqual(review.status, self.status_new)