Merge: Safe call operator
[nit.git] / lib / github / tests / test_api.nit
index 1976877..19538e4 100644 (file)
@@ -71,11 +71,13 @@ class MockGithubAPI
                map["/repos/nitlang/nit/issues/events/199674194"] = "repo_issues_events_199674194"
                map["/repos/nitlang/nit/pulls?page=1&per_page=3"] = "repo_pulls_nit"
                map["/repos/nitlang/nit/pulls/1000"] = "repo_pulls_1000"
+               map["/repos/nitlang/nit/pulls/945/comments?page=1&per_page=3"] = "repo_pulls_945_comments"
+               map["/repos/nitlang/nit/pulls/comments/21010363"] = "repo_pulls_comment_21010363"
                map["/repos/nitlang/nit/commits/64ce1f"] = "repo_commits_64ce1f"
                map["/repos/nitlang/nit/commits/4e3c688d/status"] = "repo_commits_4e3c68_status"
                map["/repos/nitlang/nit/comments/8982707"] = "repo_comments_8982707"
-               map["/repos/nitlang/nit/pulls/comments/21010363"] = "repo_pulls_comment_21010363"
                map["/search/issues?q=foo repo:nitlang/nit&page=1&per_page=3"] = "repo_search_issues_nit"
+               map["/repos/nitlang/nit/stats/contributors"] = "repo_nit_contributors"
                # errors
                map["/users/not_found/not_found"] = "errors_404"
                return map
@@ -263,8 +265,6 @@ class TestGithubAPI
                assert pulls.last.title == "Mock Github API tests"
        end
 
-       # TODO contrib_stats
-
        fun test_get_branch is test do
                var branch = api.get_branch("nitlang/nit", "master")
                assert branch isa Branch
@@ -336,6 +336,12 @@ class TestGithubAPI
                assert pull.body == "Raise dead on `nitc`.\nIt's super effective...\n"
        end
 
+       fun test_get_pull_comments is test do
+               var comments = api.get_pull_comments("nitlang/nit", 945, 1, 3)
+               assert comments.length == 2
+               assert comments.first.path == "src/modelize/modelize_property.nit"
+       end
+
        fun test_get_pull_comment is test do
                var comment = api.get_pull_comment("nitlang/nit", 21010363)
                assert comment isa PullComment
@@ -381,4 +387,11 @@ class TestGithubAPI
                assert comment.body == "For testing purposes...\n"
                assert comment.commit_id == "7eacb86d1e24b7e72bc9ac869bf7182c0300ceca"
        end
+
+       fun test_contributor_stats is test do
+               var stats = api.get_repo_contrib_stats("nitlang/nit")
+               assert stats.last.author.login == "privat"
+               assert stats.last.total == 4536
+               assert stats.last.weeks.length == 575
+       end
 end