Beispiel #1
0
 def test_get_branch_tip(self):
     """
     Set the commit id to the tip of the current branch, using the default commit policy (True)
     """
     self.mock_get_commit_id_from_ref.return_value = 'b' * 40
     watched_pr = WatchedPullRequest(
         github_organization_name='org3',
         github_repository_name='repo3',
     )
     self.assertEqual(watched_pr.get_branch_tip(), 'b' * 40)
     self.assertEqual(self.mock_get_commit_id_from_ref.mock_calls, [
         call('org3/repo3', 'master', ref_type='heads'),
     ])
Beispiel #2
0
 def test_get_branch_tip(self):
     """
     Set the commit id to the tip of the current branch, using the default commit policy (True)
     """
     self.mock_get_commit_id_from_ref.return_value = 'b' * 40
     watched_pr = WatchedPullRequest(
         github_organization_name='org3',
         github_repository_name='repo3',
     )
     self.assertEqual(watched_pr.get_branch_tip(), 'b' * 40)
     self.assertEqual(self.mock_get_commit_id_from_ref.mock_calls, [
         call('org3/repo3', 'master', ref_type='heads'),
     ])
Beispiel #3
0
    def test_set_fork_name(self):
        """
        Set org & repo using the fork name
        """
        watched_pr = WatchedPullRequest()
        watched_pr.set_fork_name('org2/another-repo')
        self.assertEqual(watched_pr.github_organization_name, 'org2')
        self.assertEqual(watched_pr.github_repository_name, 'another-repo')
        watched_pr.save()  # pylint: disable=no-member

        # Check values in DB
        watched_pr = WatchedPullRequest.objects.get(pk=watched_pr.pk)
        self.assertEqual(watched_pr.github_organization_name, 'org2')
        self.assertEqual(watched_pr.github_repository_name, 'another-repo')
Beispiel #4
0
 def test_github_attributes(self):
     """
     GitHub-specific WatchedPullRequest attributes
     """
     watched_pr = WatchedPullRequest(
         github_organization_name='open-craft',
         github_pr_url='https://github.com/edx/edx-dest/pull/234',
         github_repository_name='edx',
         branch_name='test-branch',
     )
     self.assertEqual(watched_pr.fork_name, 'open-craft/edx')
     self.assertEqual(watched_pr.target_fork_name, 'edx/edx-dest')
     self.assertEqual(watched_pr.github_base_url, 'https://github.com/open-craft/edx')
     self.assertEqual(watched_pr.github_pr_number, 234)
     self.assertEqual(watched_pr.github_branch_url, 'https://github.com/open-craft/edx/tree/test-branch')
     self.assertEqual(watched_pr.repository_url, 'https://github.com/open-craft/edx.git')
     self.assertEqual(watched_pr.updates_feed, 'https://github.com/open-craft/edx/commits/test-branch.atom')
Beispiel #5
0
    def test_set_fork_name(self):
        """
        Set org & repo using the fork name
        """
        watched_pr = WatchedPullRequest()
        watched_pr.set_fork_name('org2/another-repo')
        self.assertEqual(watched_pr.github_organization_name, 'org2')
        self.assertEqual(watched_pr.github_repository_name, 'another-repo')
        watched_pr.save()

        # Check values in DB
        watched_pr = WatchedPullRequest.objects.get(pk=watched_pr.pk)
        self.assertEqual(watched_pr.github_organization_name, 'org2')
        self.assertEqual(watched_pr.github_repository_name, 'another-repo')
Beispiel #6
0
    def test_set_fork_name(self):
        """
        Set org & repo using the fork name
        """
        _, organization = make_user_and_organization(org_name="Org2", org_handle="org2")
        watched_fork = WatchedForkFactory(organization=organization, fork='some-name')
        watched_pr = WatchedPullRequest(watched_fork=watched_fork)
        watched_pr.set_fork_name('org2/another-repo')
        self.assertEqual(watched_pr.github_organization_name, 'org2')
        self.assertEqual(watched_pr.github_repository_name, 'another-repo')
        watched_pr.save()

        # Check values in DB
        watched_pr = WatchedPullRequest.objects.get(pk=watched_pr.pk)
        self.assertEqual(watched_pr.github_organization_name, 'org2')
        self.assertEqual(watched_pr.github_repository_name, 'another-repo')