Ejemplo n.º 1
0
    def testGetTravisTokenError(self):
        self.mock_request.return_value = (403, 'Unauthorized.')

        with self.assertRaisesRegex(
                travis.TravisApiError,
            (r'Travis API Exception \(HTTP 403\): '
             r'Travis Auth API request failed with response: Unauthorized\.')):
            travis.TravisApi()
Ejemplo n.º 2
0
    def testFetchBuildsError(self, unused_mock_get_travis_token):
        travis_api = travis.TravisApi()
        self.mock_request.return_value = (500, 'Server error.')

        with self.assertRaisesRegex(
                travis.TravisApiError,
            (r'Travis API Exception \(HTTP 500\): '
             r'Travis Builds API request failed with response: Server error\.'
             )):
            travis_api.fetch_builds()
Ejemplo n.º 3
0
    def testGetTravisToken(self):
        self.mock_request.return_value = (200, {
            'access_token': '__travis_token__'
        })

        travis_api = travis.TravisApi()

        self.assertEqual(travis_api.api_token, '__travis_token__')
        self.mock_request.assert_called_once_with(
            travis_api.client, 'POST',
            '/auth/github?github_token=__github_token__', mock.ANY, mock.ANY)
Ejemplo n.º 4
0
    def testFetchBuildsPage(self, unused_mock_get_travis_token):
        self.mock_request.return_value = (200, {'builds': [self.build_json]})

        travis_api = travis.TravisApi()
        fetched_builds = travis_api.fetch_builds(page_num=1)

        # Comparing the Build directly fails due to internal state properties used
        # by SQLAlchemy.
        self.assertEqual(fetched_builds[0].started_at, self.build.started_at)
        self.assertEqual(fetched_builds[0].id, self.build.id)
        self.assertEqual(fetched_builds[0].number, self.build.number)
        self.assertEqual(fetched_builds[0].duration, self.build.duration)
        self.assertEqual(fetched_builds[0].commit_hash, self.build.commit_hash)
        self.assertEqual(fetched_builds[0].state, self.build.state)
Ejemplo n.º 5
0
 def __init__(self):
   self.travis = travis.TravisApi()
   self.session = db.Session()
   self.cursor = None