Example #1
0
 def testInvalidInput(self, print_, reqs_):
     printUserRepos(1)
     self.assertEqual(print_.call_args_list,
                      [call('Input must be a string')],
                      "invalid input so input must be string expected")
     self.assertEqual(reqs_.call_args_list, [],
                      'invalid input so no calls expected')
Example #2
0
 def testNoReposForUser(self, print_, reqs_):
     printUserRepos('sdfsdfsdfsdfsdfsdf')
     self.assertEqual(print_.call_args_list, [],
                      "no repos should have been found for the user")
     self.assertEqual(
         reqs_.call_args_list,
         [call('https://api.github.com/users/sdfsdfsdfsdfsdfsdf/repos')],
         'expected user without any repos to be called')
Example #3
0
 def testUnknownUserId(self, print_, reqs_):
     printUserRepos('sdflkjsdflkjsdflkjsdflkjsdflkjsdlfkjsdflkjsdlkjsdf')
     self.assertEqual(print_.call_args_list, [call('UserID not found')],
                      "userID error check")
     self.assertEqual(reqs_.call_args_list, [
         call(
             'https://api.github.com/users/sdflkjsdflkjsdflkjsdflkjsdflkjsdlfkjsdflkjsdlkjsdf/repos'
         )
     ], 'expected invalid user to be called')
Example #4
0
 def testBadResponses(self, print_, reqs_):
     printUserRepos('bad-request')
     self.assertEqual(print_.call_args_list,
                      [call('Cannot contact github')],
                      "bad request so cannot contact github expected")
     self.assertEqual(
         reqs_.call_args_list,
         [call('https://api.github.com/users/bad-request/repos')],
         'expected bad-request to be called only')
Example #5
0
 def testBasic(self, print_, reqs_):
     printUserRepos('richkempinski')
     self.assertEqual(print_.call_args_list, [
         call('Repo: hellogitworld Number of commits: 30'),
         call('Repo: helloworld Number of commits: 2'),
         call('Repo: Project1 Number of commits: 2'),
         call('Repo: threads-of-life Number of commits: 1')
     ], "invalid results for userID 'richkempinski'")
     self.assertEqual(
         reqs_.call_args_list, [
             call('https://api.github.com/users/richkempinski/repos'),
             call(
                 'https://api.github.com/repos/richkempinski/hellogitworld/commits'
             ),
             call(
                 'https://api.github.com/repos/richkempinski/helloworld/commits'
             ),
             call(
                 'https://api.github.com/repos/richkempinski/Project1/commits'
             ),
             call(
                 'https://api.github.com/repos/richkempinski/threads-of-life/commits'
             )
         ], "invalid calls for requests when getting 'richkempinski'")