コード例 #1
0
    def test_assignee_count(self, mock_config):
        mock_config.get_config_value = mock.MagicMock(
            return_value='jira_points_field')
        # App init, necessary to get to the logging service
        app = self.get_app()

        # Init the Import Data Class
        import_data = ImportData(app.log, mock_config)

        assignee_count_answer = {
            'johnd': {
                'displayName': 'John Doe',
                'points': 10,
                'tickets': 1
            },
            'brucew': {
                'displayName': 'Bruce Wayne',
                'points': 22,
                'tickets': 2
            },
            'darthv': {
                'displayName': 'Darth Vader',
                'points': 5,
                'tickets': 2
            }
        }
        assignee_count_response = import_data.assignee_count(
            self.get_jira_issues()['issues'])

        # Send a couple of issues and ensure returned value are correct
        self.assertEqual(assignee_count_response, assignee_count_answer)
コード例 #2
0
    def test_get_remaining_work(self, mock_config, mock_jira, mock_files):
        mock_config.get_config_value = mock.MagicMock(
            return_value='jira_points_field')
        mock_jira.get_remaining_tickets = mock.MagicMock(
            return_value=self.get_jira_issues())
        mock_files.json_write = mock.MagicMock(return_value=True)

        # App init, necessary to get to the logging service
        app = self.get_app()

        import_data = ImportData(app.log, mock_config)
        import_data.jira = mock_jira
        import_data.files = mock_files

        get_remaining_work_answer = {
            'points': 37,
            'tickets': 5,
            'types': {
                'defect': {
                    'type': 'defect',
                    'points': 30,
                    'tickets': 3
                },
                'story': {
                    'type': 'story',
                    'points': 7,
                    'tickets': 2
                }
            },
            'assignees': {
                'johnd': {
                    'displayName': 'John Doe',
                    'points': 10,
                    'tickets': 1
                },
                'brucew': {
                    'displayName': 'Bruce Wayne',
                    'points': 22,
                    'tickets': 2
                },
                'darthv': {
                    'displayName': 'Darth Vader',
                    'points': 5,
                    'tickets': 2
                }
            }
        }
        self.assertDictEqual(import_data.get_remaining_work(),
                             get_remaining_work_answer)
コード例 #3
0
    def test_count_story_points(self, mock_config):
        mock_config.get_config_value = mock.MagicMock(
            return_value='jira_points_field')
        points_per_story = 3
        expected_result = points_per_story * len(
            self.get_jira_issues()['issues'])

        # App init, necessary to get to the logging service
        app = self.get_app()

        # Init the Import Data Class
        import_data = ImportData(app.log, mock_config)
        import_data.get_story_points = mock.MagicMock(
            return_value=points_per_story)
        self.assertEqual(
            import_data.count_story_points(self.get_jira_issues()['issues']),
            expected_result)
コード例 #4
0
    def test_refresh_dailydata_cache(self, mock_config, mock_jira):
        mock_config.get_config_value = mock.MagicMock(
            return_value='jira_points_field')
        mock_jira.get_completed_tickets = mock.MagicMock(
            return_value=self.get_jira_issues())

        start_date = datetime.strptime('2017-05-28', '%Y-%m-%d').date()
        end_date = datetime.strptime('2017-05-21', '%Y-%m-%d').date()

        # App init, necessary to get to the logging service
        app = self.get_app()

        import_data = ImportData(app.log, mock_config)
        import_data.jira = mock_jira

        # To simplify formatting, re-run the full expected answer through the function
        refresh_daily_data_cache_response = import_data.refresh_dailydata_cache(
            self.get_data_completion(), start_date, end_date)

        self.assertDictEqual(refresh_daily_data_cache_response,
                             self.get_data_completion_answer())
コード例 #5
0
    def test_get_story_point(self, mock_config):
        #mock_config.get_config_value.return_value = 'jira_points_field'
        mock_config.get_config_value = mock.MagicMock(
            return_value='jira_points_field')

        # App init, necessary to get to the logging service
        app = self.get_app()

        # Init the Import Data Class
        import_data = ImportData(app.log, mock_config)

        # If field exists and send 1, should return 1
        self.assertEqual(
            import_data.get_story_points({'fields': {
                'jira_points_field': 1
            }}), 1)
        # If field does not exist and send 1, should return none
        self.assertEqual(
            import_data.get_story_points({'fields': {
                'does_not_exist': 1
            }}), None)
コード例 #6
0
    def test_story_types_count(self, mock_config):
        mock_config.get_config_value = mock.MagicMock(
            return_value='jira_points_field')

        # App init, necessary to get to the logging service
        app = self.get_app()

        # Init the Import Data Class
        import_data = ImportData(app.log, mock_config)

        # Send a couple of issues and ensure returned value are correct
        self.assertEqual(
            import_data.story_types_count(self.get_jira_issues()['issues']), {
                'story': {
                    'tickets': 2,
                    'points': 7,
                    'type': 'story'
                },
                'defect': {
                    'tickets': 3,
                    'points': 30,
                    'type': 'defect'
                }
            })
コード例 #7
0
    def refresh_jira_cache(self):
        self.log.info('Load updated data from Jira into Cache')
        date_start = self.time.get_current_date()
        date_end = self.time.get_end_date()
        self.log.info('Load.main(): Start Date: ' +
                      date_start.strftime('%Y-%m-%d'))
        self.log.info('Load.main(): End Date: ' +
                      date_end.strftime('%Y-%m-%d'))

        loader = ImportData(self.log, self.config)
        # Import existing data (if any) into a Python object
        previous_data = Files(self.log).jsonl_load(
            self.config.filepath_data_completion)
        # Refresh the cache by checking if additional days can be added
        daily_data = loader.refresh_dailydata_cache(previous_data, date_start,
                                                    date_end)
        # Write back the data cache to file after clearing any existing one
        loader.write_dailydata_cache(daily_data)

        # Call Jira to get Remaining work
        remaining_work = loader.get_remaining_work()

        return daily_data, remaining_work