Exemplo n.º 1
0
    def test_single_pr_stats_dataframe(self, workitemsMock, commitsByRepoMock, prCommits, prsByProject, prThreads):
        emptyResponse = {"value": []}
        commitsByRepoMock.side_effect = [self.mockedRepoCommitsResponse['value'], emptyResponse['value']]
        prThreads.return_value = self.mockedPrThreadsResponse['value']
        prsByProject.return_value = self.mockedRepoPrResponse['value']
        prCommits.return_value = self.mockedPrCommitsResponse['value']
        workitemsMock.return_value = self.mockedWorkitemDetailsResponse['value']
        expectedDataframeSize = 54
        client = AzureDevopsInsights("myorg", "my-super-project", ["repo1"], "team-buffalo")
        dataframe = client.collectPullRequestActivity("11c")
        self.assertEqual(len(dataframe), expectedDataframeSize)

        agg = aggregateDataframe(dataframe)

        self.assertEqual(len(agg), 1)
        self.assertEqual(agg.loc['44', 'prs_submitted'], 4)
        self.assertEqual(agg.loc['44', 'prs_merged'], 1)
        self.assertEqual(agg.loc['44', 'pr_completion_days'], 2)
        self.assertEqual(agg.loc['44', 'pr_comments'], 12)
        self.assertEqual(agg.loc['44', 'prs_reviewed'], 1)
        self.assertEqual(agg.loc['44', 'pr_commits_pushed'], 32)
        self.assertEqual(agg.loc['44', 'commit_change_count_additions'], 20)
        self.assertEqual(agg.loc['44', 'commit_change_count_edits'], 0)
        self.assertEqual(agg.loc['44', 'commit_change_count_deletes'], 12)
        self.assertEqual(agg.loc['44', 'user_stories_assigned'], 2)
        self.assertEqual(agg.loc['44', 'user_stories_completed'], 1)
        self.assertEqual(agg.loc['44', 'user_story_points_assigned'], 12)
        self.assertEqual(agg.loc['44', 'user_story_completion_days'], 1)
        self.assertEqual(agg.loc['44', 'user_stories_created'], 3)
Exemplo n.º 2
0
    def test_repo_commits_stats(self, commitsByRepoMock):
        emptyResponse = {"value": []}
        commitsByRepoMock.side_effect = [self.mockedRepoCommitsResponse['value'], emptyResponse['value']]
        client = AzureDevopsInsights("myorg", "my-super-project", ["repo1"], "team-buffalo")
        response = client.repoCommits("", "repo1")

        self.assertEqual(len(response), 8)
        self.assertEqual(response['3104bd0b0accbc74278fe6880e53215f6b93a5cd']['Add'], 1)
        self.assertEqual(response['9991b4f66def4c0a9ad8f9f27043ece7eddcf1c7']['Delete'], 1)
Exemplo n.º 3
0
    def test_repo_pr_threads_stats(self, mock_get):
        # Configuring the mock to return a response with an OK status code. Also, the mock should have
        # a `json()` method that returns a list of pr threads.

        mock_get.return_value = Mock(ok=True)
        mock_get.return_value.json.return_value = self.mockedPrThreadsResponse
        client = AzureDevopsInsights("myorg", "my-super-project", ["repo1"], "team-buffalo")
        response = client.invokePRCommentThreadsAPICall("", "repo1", "1")

        self.assertEqual(len(response), 8)
Exemplo n.º 4
0
    def test_invoke_workitem_api(self, invokeAPICallMock):
        invokeAPICallMock.side_effect = [self.mockedWorkitemListResponse['workItems'], self.mockedWorkitemDetailsResponse['value']]
        client = AzureDevopsInsights("myorg", "my-super-project", ["repo1"], "team-buffalo")
        response = client.invokeWorkitemsAPICall("", "team-buffalo")

        self.assertEqual(len(response), 3)