Пример #1
0
 def setUp(self):
     """Define the test client and other test variables."""
     user = create_test_user()
     self.tms = mock_up_TMS(user)
     self.tms.save()
     self.project_name = "etabot"
     self.project_mode = "scrum"
     self.project_open_status = "ToDo"
     self.project_grace_period = "24"
     self.project_work_hours = {
         1: (10, 14),
         2: (16, 20),
         3: (10, 14),
         4: (16, 18),
         5: (20, 21),
         6: (23, 23),
         0: (9, 10)
     }
     self.project_vacation_days = {
         1: ('2017-04-21', '2017-04-30'),
         2: ('2017-05-16', '2017-05-19'),
         3: ('2017-05-24', '2017-05-24'),
         4: ('2017-05-29', '2017-05-29')
     }
     self.project = Project(owner=user,
                            project_tms=self.tms,
                            name=self.project_name,
                            mode=self.project_mode,
                            open_status=self.project_open_status,
                            grace_period=self.project_grace_period,
                            work_hours=self.project_work_hours,
                            vacation_days=self.project_vacation_days)
Пример #2
0
    def setUp(self):
        # Create test user
        self.user = User.objects.create_user('testuser',
                                             '*****@*****.**',
                                             'testpassword')

        # Create test TMS
        self.tms = TMS(owner=self.user, **test_tms_data)
        self.tms.save()

        # Create test project
        self.project_name = 'ETAbot-Demo'
        self.project_mode = 'scrum'
        self.project_open_status = "ToDo"
        self.project_grace_period = '1'
        self.project_work_hours = {1: (10, 11)}
        self.project_vacation_days = [('2017-04-21', '2017-04-30')]
        self.project = Project(owner=self.user,
                               project_tms=self.tms,
                               name=self.project_name,
                               mode=self.project_mode,
                               open_status=self.project_open_status,
                               grace_period=self.project_grace_period,
                               work_hours=self.project_work_hours,
                               vacation_days=self.project_vacation_days,
                               project_settings={})
        self.project.save()
Пример #3
0
    def setUp(self):
        # We want to go ahead and originally create a user.
        self.user = User.objects.create_user('testuser',
                                             '*****@*****.**',
                                             'testpassword')

        # Test user must have valid email to test!
        logging.debug('self.user.email: {}'.format(self.user.email))
        self.assertTrue('*****@*****.**' == self.user.email)

        self.tms = TMS(owner=self.user, **test_tms_data)
        self.tms.save()
        self.project_name = "ETAbot-Demo"
        self.project_mode = "scrum"
        self.project_open_status = "ToDo"
        self.project_grace_period = "24"
        self.project_work_hours = {
            1: (10, 14), 2: (16, 20), 3: (10, 14), 4: (16, 18), 5: (20, 21), 6: (23, 23), 0: (9, 10)}
        self.project_vacation_days = [
            ('2017-04-21', '2017-04-30'),
            ('2017-05-16', '2017-05-19'),
            ('2017-05-24', '2017-05-24'),
            ('2017-05-29', '2017-05-29')]
        self.project = Project(owner=self.user, project_tms=self.tms,
                               name=self.project_name,
                               mode=self.project_mode,
                               open_status=self.project_open_status,
                               grace_period=self.project_grace_period,
                               work_hours=self.project_work_hours,
                               vacation_days=self.project_vacation_days,
                               project_settings={})
        self.project.save()
Пример #4
0
class TestEmailNotificationsTestCases(TestCase):
    def setUp(self):
        # We want to go ahead and originally create a user.
        self.user = User.objects.create_user('testuser',
                                             '*****@*****.**',
                                             'testpassword')

        #Test user must have valid email to test!
        logging.debug('self.user.email: {}'.format(self.user.email))
        self.assertTrue('*****@*****.**' == self.user.email)

        self.tms = TMS(owner=self.user, **test_tms_data)
        self.tms.save()
        self.project_name = "ETAbot-Demo"
        self.project_mode = "scrum"
        self.project_open_status = "ToDo"
        self.project_grace_period = "24"
        self.project_work_hours = {
            1: (10, 14),
            2: (16, 20),
            3: (10, 14),
            4: (16, 18),
            5: (20, 21),
            6: (23, 23),
            0: (9, 10)
        }
        self.project_vacation_days = [('2017-04-21', '2017-04-30'),
                                      ('2017-05-16', '2017-05-19'),
                                      ('2017-05-24', '2017-05-24'),
                                      ('2017-05-29', '2017-05-29')]
        self.project = Project(owner=self.user,
                               project_tms=self.tms,
                               name=self.project_name,
                               mode=self.project_mode,
                               open_status=self.project_open_status,
                               grace_period=self.project_grace_period,
                               work_hours=self.project_work_hours,
                               vacation_days=self.project_vacation_days,
                               project_settings={})
        self.project.save()

    def test_send_daily_project_report(self):
        # eta_tasks.generate_email_report(self.tms,[self.project.id],self.user)
        dt.send_daily_project_report(include_active_sprints=True,
                                     include_future_sprints=True,
                                     include_backlog=True,
                                     pickle_df=False)
        # If we make it here with no exits, assert a pass.
        self.assertEqual(1, 1)

    def test_estimate_ETA_for_TMS(self):
        assert isinstance(self.project, Project)
        assert isinstance(self.project.project_settings, dict)
        et.estimate_ETA_for_TMS(self.tms, [self.project])
Пример #5
0
class TestStoreReportDateInProjectSettings(TestCase):
    """Test for report date generation."""
    def setUp(self):
        # Create test user
        self.user = User.objects.create_user('testuser',
                                             '*****@*****.**',
                                             'testpassword')

        # Create test TMS
        self.tms = TMS(owner=self.user, **test_tms_data)
        self.tms.save()

        # Create test project
        self.project_name = 'ETAbot-Demo'
        self.project_mode = 'scrum'
        self.project_open_status = "ToDo"
        self.project_grace_period = '1'
        self.project_work_hours = {1: (10, 11)}
        self.project_vacation_days = [('2017-04-21', '2017-04-30')]
        self.project = Project(owner=self.user,
                               project_tms=self.tms,
                               name=self.project_name,
                               mode=self.project_mode,
                               open_status=self.project_open_status,
                               grace_period=self.project_grace_period,
                               work_hours=self.project_work_hours,
                               vacation_days=self.project_vacation_days,
                               project_settings={})
        self.project.save()

    def test_is_report_in_project_settings(self):
        """Test that reports are generated with a timestamp and hierarchical report."""
        # Create report
        et.estimate_ETA_for_TMS(self.tms, [self.project])
        # Check report exists and is a dictionary
        assert isinstance(self.project.project_settings, dict)
        # Check if the report_date is generated
        self.assertTrue('report_date' in self.project.project_settings)
        # Check if report_date is of type str
        self.assertTrue(
            isinstance(self.project.project_settings['report_date'], str))
        self.assertTrue('hierarchical_report' in self.project.project_settings)
        hierarchical_report = self.project.project_settings[
            'hierarchical_report']
        self.assertTrue(isinstance(hierarchical_report, dict))
        hierarchical_report_json = json.dumps(hierarchical_report)
        assert isinstance(hierarchical_report_json, str)
Пример #6
0
class ProjectModelTestCase(TestCase):
    """This class defines the test suite for the project model."""
    def setUp(self):
        """Define the test client and other test variables."""
        user = create_test_user()
        self.tms = mock_up_TMS(user)
        self.tms.save()
        self.project_name = "etabot"
        self.project_mode = "scrum"
        self.project_open_status = "ToDo"
        self.project_grace_period = "24"
        self.project_work_hours = {
            1: (10, 14),
            2: (16, 20),
            3: (10, 14),
            4: (16, 18),
            5: (20, 21),
            6: (23, 23),
            0: (9, 10)
        }
        self.project_vacation_days = {
            1: ('2017-04-21', '2017-04-30'),
            2: ('2017-05-16', '2017-05-19'),
            3: ('2017-05-24', '2017-05-24'),
            4: ('2017-05-29', '2017-05-29')
        }
        self.project = Project(owner=user,
                               project_tms=self.tms,
                               name=self.project_name,
                               mode=self.project_mode,
                               open_status=self.project_open_status,
                               grace_period=self.project_grace_period,
                               work_hours=self.project_work_hours,
                               vacation_days=self.project_vacation_days)

    def test_model_can_create_a_project(self):
        """Test the user model can create a project."""
        old_count = Project.objects.count()
        self.project.save()
        new_count = Project.objects.count()
        self.assertNotEqual(old_count, new_count)
Пример #7
0
class TestCeleryTasks(TestCase):

    def setUp(self):
        # We want to go ahead and originally create a user.
        self.user = User.objects.create_user('testuser',
                                             '*****@*****.**',
                                             'testpassword')

        # Test user must have valid email to test!
        logging.debug('self.user.email: {}'.format(self.user.email))
        self.assertTrue('*****@*****.**' == self.user.email)

        self.tms = TMS(owner=self.user, **test_tms_data)
        self.tms.save()
        self.project_name = "ETAbot-Demo"
        self.project_mode = "scrum"
        self.project_open_status = "ToDo"
        self.project_grace_period = "24"
        self.project_work_hours = {
            1: (10, 14), 2: (16, 20), 3: (10, 14), 4: (16, 18), 5: (20, 21), 6: (23, 23), 0: (9, 10)}
        self.project_vacation_days = [
            ('2017-04-21', '2017-04-30'),
            ('2017-05-16', '2017-05-19'),
            ('2017-05-24', '2017-05-24'),
            ('2017-05-29', '2017-05-29')]
        self.project = Project(owner=self.user, project_tms=self.tms,
                               name=self.project_name,
                               mode=self.project_mode,
                               open_status=self.project_open_status,
                               grace_period=self.project_grace_period,
                               work_hours=self.project_work_hours,
                               vacation_days=self.project_vacation_days,
                               project_settings={})
        self.project.save()

    def test_celery_task_record_for_estimate_all(self):
        """Ensure that celery tasks records are created and added as objects within the models database
        when estimate_all() method is run."""
        # created_celery_task = dt.estimate_all._original()
        parse_tms_kwargs = {}
        # tms = MagicMock(spec=TMS)
        celery_task_result = ct.send_celery_task_with_tracking(
                    'etabotapp.django_tasks.parse_projects_for_tms_id',
                    (self.tms.id, parse_tms_kwargs), owner=self.tms.owner)
        created_celery_task_record = CeleryTask.objects.get(task_id=celery_task_result.id)

        # As of 5/17/21 this assertion is passing....
        self.assertEqual(created_celery_task_record.task_id, celery_task_result.id)

        task_id = created_celery_task_record.task_id
        task_name = created_celery_task_record.task_name
        start_time = created_celery_task_record.start_time
        end_time = created_celery_task_record.end_time
        status = created_celery_task_record.status
        owner = created_celery_task_record.owner
        meta_data = created_celery_task_record.meta_data

        # Ensure unique task_id
        objects_in_db = CeleryTask.objects.filter(task_id=task_id)
        num_in_db = objects_in_db.count()
        self.assertEqual(num_in_db, 1)

        self.assertEqual(objects_in_db[0].task_name, task_name)
        self.assertEqual(objects_in_db[0].start_time, start_time)
        self.assertEqual(objects_in_db[0].end_time, end_time)
        self.assertEqual(objects_in_db[0].status, status)
        self.assertEqual(objects_in_db[0].owner, owner)
        self.assertEqual(objects_in_db[0].meta_data, meta_data)