Example #1
0
    def test_that_add_manager_to_project_if_not_added_yet_function_should_add_specified_user_as_manager_to_project(
            self):
        project = Project.objects.filter_suspended().get()

        user = UserFactory(user_type=CustomUser.UserType.MANAGER.name)

        GenerateTestDataCommand._add_manager_to_project_if_not_added_yet(
            project, user)

        self.assertIn(user, project.managers.all())
        self.assertNotIn(user, project.members.all())
Example #2
0
 def test_admin_and_superuser_should_have_user_type_coded_as_admin(
         self, user_type):
     self.assertEqual(
         GenerateTestDataCommand._set_user_factory_parameters(
             user_type).get("user_type"),
         CustomUser.UserType.ADMIN.name,
     )
Example #3
0
    def test_stop_date_should_be_of_datetime_type_and_set_in_past(self):
        stop_date_returned_by_function = GenerateTestDataCommand._create_stop_date(
        )

        self.assertIsInstance(stop_date_returned_by_function,
                              timezone.datetime)
        self.assertLess(stop_date_returned_by_function, timezone.now())
Example #4
0
    def test_that_check_that_user_is_member_of_any_project_function_should_return_true_if_user_is_member_of_any_project(
            self):
        project = Project.objects.first()

        project.members.add(self.user)

        self.assertTrue(
            GenerateTestDataCommand.check_that_user_is_member_of_any_project(
                self.user))
Example #5
0
    def test_that_pick_random_user_project_function_should_return_one_of_projects_that_user_is_member_of(
            self):
        for project in Project.objects.all():
            project.members.add(self.user)

        returned_project = GenerateTestDataCommand._pick_random_user_project(
            self.user)

        self.assertIn(returned_project, self.user.projects.all())
Example #6
0
    def test_that_get_list_of_users_function_should_return_list_of_users_of_specified_type(
            self, user_type):
        UserFactory(user_type=CustomUser.UserType.ADMIN.name)
        UserFactory(user_type=CustomUser.UserType.EMPLOYEE.name)
        UserFactory(user_type=CustomUser.UserType.MANAGER.name)
        UserFactory(user_type=CustomUser.UserType.ADMIN.name,
                    is_superuser=True)

        returned_user_type = GenerateTestDataCommand._get_list_of_users(
            user_type)[0].user_type

        self.assertEqual(returned_user_type, user_type)
Example #7
0
    def test_that_get_random_work_hours_function_should_return_timedelta_object_of_seconds_less_than_max_hours_per_day(
            self, number_of_reports):
        work_hours_result = GenerateTestDataCommand._get_random_work_hours(
            number_of_reports,
            max_work_hours_per_day=GenerateTestDataCommand.
            MAX_WORK_HOURS_PER_DAY)

        self.assertLess(
            work_hours_result,
            timezone.timedelta(
                hours=GenerateTestDataCommand.MAX_WORK_HOURS_PER_DAY /
                number_of_reports),
        )
Example #8
0
 def test_employee_and_manager_should_have_user_type_coded_as_based_of_user_type_name(
         self, user_type):
     self.assertEqual(
         GenerateTestDataCommand._set_user_factory_parameters(
             user_type).get("user_type"), user_type)
Example #9
0
 def test_superuser_should_have_superuser_property(self):
     self.assertTrue(
         GenerateTestDataCommand._set_user_factory_parameters(
             SUPERUSER_USER_TYPE).get("is_superuser"))
Example #10
0
 def test_any_user_should_not_have_superuser_property_except_superuser(
         self, user_type):
     self.assertFalse(
         GenerateTestDataCommand._set_user_factory_parameters(
             user_type).get("is_superuser"))
Example #11
0
 def test_that_check_that_user_is_member_of_any_project_function_should_return_false_if_user_is_not_in_any_project(
         self):
     self.assertFalse(
         GenerateTestDataCommand.check_that_user_is_member_of_any_project(
             self.user))
Example #12
0
    def test_that_create_task_activities_function_should_create_tasks_activities(
            self):
        GenerateTestDataCommand.create_task_activities()

        self.assertEqual(TaskActivityType.objects.count(), 17)
Example #13
0
 def test_that_get_list_of_projects_function_should_raise_error_when_project_type_is_not_valid(
         self):
     with self.assertRaises(UnsupportedProjectTypeException):
         GenerateTestDataCommand._get_list_of_projects("error")