Exemple #1
0
 def test_nr_manual_ltcs(self, mock_nr_issues):
     """ Tests that the function invokes correct custom jira filter number instead of the query. """
     backlog = JiraBacklog('url!', 'username!', 'password!', 'Project Name', 'unimportant')
     mock_nr_issues.return_value = 1, ['a']
     result = backlog.nr_manual_ltcs()
     self.assertEqual((1, ['a']), result)
     mock_nr_issues.assert_called_once_with(JQL_CONFIG["nr_manual_ltcs"].format(project='Project Name'))
Exemple #2
0
 def test_nr_user_stories(self, mock_nr_issues):
     """ Tests that the function invokes correct default jql query. """
     mock_nr_issues.return_value = 1, ['a']
     backlog = JiraBacklog('url!', 'username!', 'password!', 'project!', 'unimportant')
     result = backlog.nr_user_stories()
     self.assertEqual((1, ['a']), result)
     mock_nr_issues.assert_called_once_with('project = "project!" AND type = Story')
Exemple #3
0
 def test_nr_ltcs_to_be_automated(self, mock_nr_issues):
     """ Tests that the function invokes correct default jql query. """
     mock_nr_issues.return_value = 1, ['a']
     backlog = JiraBacklog('url!', 'username!', 'password!', 'project!', 'unimportant')
     result = backlog.nr_ltcs_to_be_automated()
     self.assertEqual((1, ['a']), result)
     mock_nr_issues.assert_called_once()
Exemple #4
0
 def test_init(self, mock_init, mock_nr_issues):
     """ Tests that the inner JiraFilter is initialized with correct parameters """
     mock_init.return_value = None
     backlog = JiraBacklog('url!', 'username!', 'password!', 'project!', 'unimportant')
     backlog.nr_user_stories()
     mock_nr_issues.assert_called_once()
     mock_init.assert_called_once_with('url!', 'username!', 'password!')
     self.assertEqual('Jira backlog', backlog.metric_source_name)
Exemple #5
0
 def test_nr_ltcs_to_be_automated_custom_filter_number(self, mock_nr_issues):
     """ Tests that the function invokes correct custom jira filter number instead of the query. """
     mock_nr_issues.return_value = 1, ['a']
     backlog = JiraBacklog('url!', 'username!', 'password!', 'whatever!?', 'unimportant',
                           jql_config={"nr_ltcs_to_be_automated": [11, '12']})
     result = backlog.nr_ltcs_to_be_automated()
     self.assertEqual((1, ['a']), result)
     mock_nr_issues.assert_called_once_with('11', '12')
Exemple #6
0
 def test_nr_ltcs_to_be_automated_custom(self, mock_nr_issues):
     """ Tests that the function invokes correct custom jql query. """
     mock_nr_issues.return_value = 1, ['a']
     backlog = JiraBacklog('url!', 'username!', 'password!', 'project!', 'unimportant',
                           jql_config={"nr_ltcs_to_be_automated": ['1st {project}', '2nd {project}']})
     result = backlog.nr_ltcs_to_be_automated()
     self.assertEqual((1, ['a']), result)
     mock_nr_issues.assert_called_once_with('1st project!', '2nd project!')
Exemple #7
0
    def test_nr_user_stories_with_sufficient_ltcs_error(self, mock_get_query, mock_get_field_id):
        """ Tests that the function invokes correct default jql query. """
        mock_get_field_id.return_value = None
        backlog = JiraBacklog('url!', 'username!', 'password!', 'project!', 'custom_field_name')

        result = backlog.nr_user_stories_with_sufficient_ltcs()

        self.assertEqual((-1, []), result)
        mock_get_field_id.assert_called_once_with('custom_field_name')
        mock_get_query.assert_not_called()
Exemple #8
0
    def test_nr_user_stories_with_sufficient_ltcs(self, mock_get_query, mock_get_field_id):
        """ Tests that the function invokes correct default jql query. """
        mock_get_query.return_value = {"issues": [{"fields": {"custom_123": 1, "issuelinks": [{"id": "1"}]}}]}
        mock_get_field_id.return_value = 'custom_123'
        backlog = JiraBacklog('url!', 'username!', 'password!', 'project!', 'custom_field_name')

        result = backlog.nr_user_stories_with_sufficient_ltcs()

        self.assertEqual((1, [{"fields": {"custom_123": 1, "issuelinks": [{"id": "1"}]}}]), result)
        mock_get_field_id.assert_called_once_with('custom_field_name')
Exemple #9
0
    def test_nr_user_stories_with_sufficient_ltcs_field(self, mock_error, mock_get_query, mock_get_field_id):
        """ Tests that the function invokes correct default jql query. """
        mock_get_query.return_value = {"issues": [{"fields": {"issuelinks": [{"id": "1"}]}}]}
        mock_get_field_id.return_value = 'missing_custom_field'
        backlog = JiraBacklog('url!', 'username!', 'password!', 'project!', 'custom_field_name')

        result = backlog.nr_user_stories_with_sufficient_ltcs()

        self.assertEqual((-1, []), result)
        mock_get_field_id.assert_called_once_with('custom_field_name')
        self.assertEqual('Error processing jira response. The key %s not found!', mock_error.call_args_list[0][0][0])
        self.assertIsInstance(mock_error.call_args_list[0][0][1], KeyError)
Exemple #10
0
    def test_nr_user_stories_with_sufficient_ltcs_multi(self, mock_get_query, mock_get_field_id):
        """ Tests that the function invokes correct default jql query. """
        mock_get_query.side_effect = [{"issues": [{"fields": {"custom_123": 1, "issuelinks": [{"id": "1"}]}}]},
                                      {"issues": [{"fields": {"custom_123": 1, "issuelinks": [{"id": "2"}]}}]}]
        mock_get_field_id.return_value = 'custom_123'
        backlog = JiraBacklog('url!', 'username!', 'password!', 'project!', 'custom_field_name',
                              jql_config={"nr_user_stories_with_sufficient_ltcs": ['1st {project}', '2nd {project}']})

        result = backlog.nr_user_stories_with_sufficient_ltcs()

        self.assertEqual((2, [{"fields": {"custom_123": 1, "issuelinks": [{"id": "1"}]}},
                              {"fields": {"custom_123": 1, "issuelinks": [{"id": "2"}]}}]), result)
        mock_get_field_id.assert_called_once_with('custom_field_name')
        self.assertEqual([call('1st project!'), call('2nd project!')], mock_get_query.call_args_list)
Exemple #11
0
 def test_nr_manual_ltcs_too_old_custom_filter_number(self):
     """ Tests that the function invokes correct custom jira filter number instead of the query. """
     backlog = JiraBacklog('url!', 'username!', 'password!', 'whatever!?', 'unimportant')
     self.assertEqual(-1, backlog.nr_manual_ltcs_too_old('1', 1))
Exemple #12
0
 def test_nr_manual_ltcs_too_old_custom(self):
     """ Tests that the function invokes correct custom jql query. """
     backlog = JiraBacklog('url!', 'username!', 'password!', 'project!', 'unimportant')
     self.assertEqual(-1, backlog.nr_manual_ltcs_too_old('1', 1))
Exemple #13
0
 def test_manual_test_execution_url(self):
     """ Tests that the function invokes correct custom jira filter number instead of the query. """
     backlog = JiraBacklog('url!', 'username!', 'password!', 'whatever!?', 'unimportant')
     self.assertEqual('', backlog.manual_test_execution_url())
Exemple #14
0
 def test_date_of_last_manual_test(self):
     """ Tests that the function invokes correct custom jira filter number instead of the query. """
     backlog = JiraBacklog('url!', 'username!', 'password!', 'whatever!?', 'unimportant')
     self.assertEqual(datetime.datetime.min, backlog.date_of_last_manual_test())
Exemple #15
0
 def test_metric_source_urls_many_issues(self):
     """ Tests that the function correctly formats display url. """
     backlog = JiraBacklog('http://url', 'username!', 'password!', 'whatever!?', 'unimportant')
     self.assertEqual(['http://url/issues/?jql=key%20in%20(issue-1%2Cissue-2)'],
                      backlog.metric_source_urls('issue-1', 'issue-2'))