def setUp(self):
        # Set up the mock release_tag lookup response
        self.repo_api_url = "https://api.github.com/repos/TestOwner/TestRepo"
        # Tag that does not exist
        self.invalid_tag = "release/1.4"
        # The current production release
        self.current_tag = "release/1.3"
        # The previous beta release
        self.beta_tag = "beta/1.3-Beta_1"
        # The previous production release with no change notes vs 1.3
        self.last_tag = "release/1.2"
        # The second previous production release with one change note vs 1.3
        self.last2_tag = "release/1.1"
        # The third previous production release with three change notes vs 1.3
        self.last3_tag = "release/1.0"

        self.current_tag_sha = self._random_sha()
        self.beta_tag_sha = self._random_sha()
        self.current_tag_commit_sha = self._random_sha()
        self.current_tag_commit_date = datetime.utcnow()
        self.last_tag_sha = self._random_sha()
        self.last_tag_commit_sha = self._random_sha()
        self.last_tag_commit_date = datetime.utcnow() - timedelta(days=1)
        self.last2_tag_sha = self._random_sha()
        self.gh = get_github_api("TestUser", "TestPass")
        self.init_github()
        self.mock_util = MockUtil("TestOwner", "TestRepo")
 def setUp(self):
     self.current_tag = 'prod/1.4'
     self.last_tag = 'prod/1.3'
     self.github_info = {
         'github_owner': 'TestOwner',
         'github_repo': 'TestRepo',
         'github_username': '******',
         'github_password': '******',
     }
     self.gh = get_github_api('TestUser', 'TestPass')
     self.mock_util = MockUtil('TestOwner', 'TestRepo')
 def setUp(self):
     self.init_github()
     self.github_info = {
         "github_owner": "TestOwner",
         "github_repo": "TestRepo",
         "github_username": "******",
         "github_password": "******",
         "master_branch": "master",
     }
     self.gh = get_github_api("TestUser", "TestPass")
     self.mock_util = MockUtil("TestOwner", "TestRepo")
 def setUp(self):
     self.current_tag = "prod/1.4"
     self.last_tag = "prod/1.3"
     self.github_info = {
         "github_owner": "TestOwner",
         "github_repo": "TestRepo",
         "github_username": "******",
         "github_password": "******",
     }
     self.gh = get_github_api("TestUser", "TestPass")
     self.mock_util = MockUtil("TestOwner", "TestRepo")
示例#5
0
 def setUp(self):
     self.init_github()
     self.gh = get_github_api("TestUser", "TestPass")
     self.title = "Issues"
     # Set up the mock release_tag lookup response
     self.issue_number_valid = 123
     self.issue_number_invalid = 456
     self.pr_number = 789
     self.pr_url = "https://github.com/{}/{}/pulls/{}".format(
         "TestOwner", "TestRepo", self.pr_number)
     self.mock_util = MockUtil("TestOwner", "TestRepo")
 def setUp(self):
     self.init_github()
     self.github_info = {
         'github_owner': 'TestOwner',
         'github_repo': 'TestRepo',
         'github_username': '******',
         'github_password': '******',
         'master_branch': 'master',
     }
     self.gh = get_github_api('TestUser', 'TestPass')
     self.mock_util = MockUtil('TestOwner', 'TestRepo')
 def setUp(self):
     self.init_github()
     self.gh = get_github_api("TestUser", "TestPass")
     self.title = "Issues"
     # Set up the mock release_tag lookup response
     self.issue_number_valid = 123
     self.issue_number_invalid = 456
     self.pr_number = 789
     self.pr_url = "https://github.com/{}/{}/pulls/{}".format(
         "TestOwner", "TestRepo", self.pr_number
     )
     self.mock_util = MockUtil("TestOwner", "TestRepo")
示例#8
0
 def setUp(self):
     self.init_github()
     self.gh = get_github_api('TestUser', 'TestPass')
     self.title = 'Issues'
     # Set up the mock release_tag lookup response
     self.issue_number_valid = 123
     self.issue_number_invalid = 456
     self.pr_number = 789
     self.pr_url = 'https://github.com/{}/{}/pulls/{}'.format(
         'TestOwner',
         'TestRepo',
         self.pr_number,
     )
     self.mock_util = MockUtil('TestOwner', 'TestRepo')
    def test_github_api_retries(self, _make_request):
        gh = get_github_api("TestUser", "TestPass")
        adapter = gh.session.get_adapter("http://")

        self.assertEqual(0.3, adapter.max_retries.backoff_factor)
        self.assertIn(502, adapter.max_retries.status_forcelist)

        _make_request.side_effect = [
            MockHttpResponse(status=503),
            MockHttpResponse(status=200),
        ]

        gh.octocat("meow")
        self.assertEqual(_make_request.call_count, 2)
示例#10
0
    def test_github_api_retries(self, _make_request):
        gh = get_github_api("TestUser", "TestPass")
        adapter = gh._session.get_adapter("http://")

        self.assertEqual(0.3, adapter.max_retries.backoff_factor)
        self.assertIn(502, adapter.max_retries.status_forcelist)

        _make_request.side_effect = [
            MockHttpResponse(status=503),
            MockHttpResponse(status=200),
        ]

        gh.octocat("meow")
        self.assertEqual(_make_request.call_count, 2)
示例#11
0
    def test_github_api_retries(self, _make_request):
        gh = get_github_api("TestUser", "TestPass")
        adapter = gh.session.get_adapter("http://")

        assert 0.3 == adapter.max_retries.backoff_factor
        assert 502 in adapter.max_retries.status_forcelist

        _make_request.side_effect = [
            MockHttpResponse(status=503),
            MockHttpResponse(status=200),
        ]

        gh.octocat("meow")
        assert 2 == _make_request.call_count
示例#12
0
 def setUp(self):
     self.init_github()
     self.gh = get_github_api("TestUser", "TestPass")
     self.mock_util = MockUtil("TestOwner", "TestRepo")
     self.title = "Issues"
     self.issue_number_without_comments = 1
     self.issue_number_with_beta_comment = 2
     self.issue_number_without_beta_comment = 3
     self.issue_number_with_prod_comment = 4
     self.issue_number_without_prod_comment = 5
     self.pr_number = 6
     self.pr_url = "http://example.com/pulls/{}".format(self.pr_number)
     self.tag_prod = "release/1.2"
     self.tag_beta = "beta/1.2-Beta_3"
     self.tag_not_prod_or_beta = "foo"
     self.version_number_prod = "1.1"
     self.version_number_beta = "1.2 (Beta 3)"
示例#13
0
    def test_github_api_retries(self, mock_http_response):
        gh = get_github_api("TestUser", "TestPass")
        adapter = gh.session.get_adapter("http://")

        assert 0.3 == adapter.max_retries.backoff_factor
        assert 502 in adapter.max_retries.status_forcelist

        with mock.patch(
                "urllib3.connectionpool.HTTPConnectionPool._make_request"
        ) as _make_request:
            _make_request.side_effect = [
                mock_http_response(status=503),
                mock_http_response(status=200),
            ]

            gh.octocat("meow")
            assert 2 == _make_request.call_count
示例#14
0
 def setUp(self):
     self.init_github()
     self.gh = get_github_api('TestUser', 'TestPass')
     self.mock_util = MockUtil('TestOwner', 'TestRepo')
     self.title = 'Issues'
     self.issue_number_without_comments = 1
     self.issue_number_with_beta_comment = 2
     self.issue_number_without_beta_comment = 3
     self.issue_number_with_prod_comment = 4
     self.issue_number_without_prod_comment = 5
     self.pr_number = 6
     self.pr_url = 'http://example.com/pulls/{}'.format(self.pr_number)
     self.tag_prod = 'prod/1.2'
     self.tag_beta = 'beta/1.2-Beta_3'
     self.tag_not_prod_or_beta = 'foo'
     self.version_number_prod = '1.1'
     self.version_number_beta = '1.2 (Beta 3)'
 def setUp(self):
     self.init_github()
     self.gh = get_github_api("TestUser", "TestPass")
     self.mock_util = MockUtil("TestOwner", "TestRepo")
     self.title = "Issues"
     self.issue_number_without_comments = 1
     self.issue_number_with_beta_comment = 2
     self.issue_number_without_beta_comment = 3
     self.issue_number_with_prod_comment = 4
     self.issue_number_without_prod_comment = 5
     self.pr_number = 6
     self.pr_url = "https://github.com/TestOwner/TestRepo/pulls/{}".format(
         self.pr_number
     )
     self.tag_prod = "release/1.2"
     self.tag_beta = "beta/1.2-Beta_3"
     self.tag_not_prod_or_beta = "foo"
     self.version_number_prod = "1.1"
     self.version_number_beta = "1.2 (Beta 3)"
示例#16
0
    def setUp(self):
        # Set up the mock release_tag lookup response
        self.repo_api_url = "https://api.github.com/repos/TestOwner/TestRepo"
        # Tag that does not exist
        self.invalid_tag = "release/1.4"
        # The current production release
        self.current_tag = "release/1.3"
        # The previous production release with no change notes vs 1.3
        self.last_tag = "release/1.2"
        # The second previous production release with one change note vs 1.3
        self.last2_tag = "release/1.1"
        # The third previous production release with three change notes vs 1.3
        self.last3_tag = "release/1.0"

        self.current_tag_sha = self._random_sha()
        self.current_tag_commit_sha = self._random_sha()
        self.current_tag_commit_date = datetime.utcnow()
        self.last_tag_sha = self._random_sha()
        self.last_tag_commit_sha = self._random_sha()
        self.last_tag_commit_date = datetime.utcnow() - timedelta(days=1)
        self.last2_tag_sha = self._random_sha()
        self.gh = get_github_api("TestUser", "TestPass")
        self.init_github()
        self.mock_util = MockUtil("TestOwner", "TestRepo")
示例#17
0
 def get_github_api(self):
     github_config = self.keychain.get_service('github')
     gh = get_github_api(github_config.username, github_config.password)
     return gh
示例#18
0
def gh_api():
    return get_github_api("TestOwner", "TestRepo")
示例#19
0
 def _init_task(self):
     self.github_config = self.project_config.keychain.get_service("github")
     self.github = get_github_api(
         username=self.github_config.username, password=self.github_config.password
     )
示例#20
0
 def get_github_api(self):  # pragma: nocover
     github_config = self.keychain.get_service("github")
     gh = get_github_api(github_config.username, github_config.password)
     return gh
示例#21
0
 def _init_task(self):
     self.github_config = self.project_config.keychain.get_service('github')
     self.github = get_github_api(
         username=self.github_config.username,
         password=self.github_config.password,
     )
示例#22
0
文件: models.py 项目: addys888/metaci
 def github_api(self):
     gh = get_github_api(settings.GITHUB_USERNAME, settings.GITHUB_PASSWORD)
     repo = gh.repository(self.owner, self.name)
     return repo
 def get_github_api(self):  # pragma: nocover
     github_config = self.keychain.get_service("github")
     gh = get_github_api(github_config.username, github_config.password)
     return gh