示例#1
0
 def test_set_to_branch_tip_replace_commit_hash(self, mock_get_commit_id_from_ref):
     """
     The hash should be updated in the instance name when updating
     """
     mock_get_commit_id_from_ref.return_value = '1234567' + 'd' * 33
     instance = OpenEdXInstanceFactory(commit_id='a' * 40, name='Test Instance (aaaaaaa)')
     instance.set_to_branch_tip(branch_name='new-branch', ref_type='tag')
     self.assertEqual(instance.name, 'Test Instance (1234567)')
示例#2
0
 def test_set_to_branch_tip_replace_commit_hash(
         self, mock_get_commit_id_from_ref):
     """
     The hash should be updated in the instance name when updating
     """
     mock_get_commit_id_from_ref.return_value = '1234567' + 'd' * 33
     instance = OpenEdXInstanceFactory(commit_id='a' * 40,
                                       name='Test Instance (aaaaaaa)')
     instance.set_to_branch_tip(branch_name='new-branch', ref_type='tag')
     self.assertEqual(instance.name, 'Test Instance (1234567)')
示例#3
0
 def test_set_to_branch_tip_extra_args(self, mock_get_commit_id_from_ref):
     """
     Set the commit id to the tip of a specified reference
     """
     mock_get_commit_id_from_ref.return_value = 'c' * 40
     instance = OpenEdXInstanceFactory(commit_id='a' * 40)
     instance.set_to_branch_tip(branch_name='new-branch', ref_type='tag')
     self.assertEqual(instance.commit_id, 'c' * 40)
     self.assertEqual(instance.branch_name, 'new-branch')
     self.assertEqual(instance.ref_type, 'tag')
示例#4
0
 def test_set_to_branch_tip_extra_args(self, mock_get_commit_id_from_ref):
     """
     Set the commit id to the tip of a specified reference
     """
     mock_get_commit_id_from_ref.return_value = 'c' * 40
     instance = OpenEdXInstanceFactory(commit_id='a' * 40)
     instance.set_to_branch_tip(branch_name='new-branch', ref_type='tag')
     self.assertEqual(instance.commit_id, 'c' * 40)
     self.assertEqual(instance.branch_name, 'new-branch')
     self.assertEqual(instance.ref_type, 'tag')
示例#5
0
    def test_set_to_branch_tip_no_commit(self, mock_get_commit_id_from_ref):
        """
        Set the commit id to the tip of the current branch, with commit=False
        """
        mock_get_commit_id_from_ref.return_value = 'b' * 40
        instance = OpenEdXInstanceFactory(commit_id='a' * 40)
        instance.set_to_branch_tip(commit=False)
        self.assertEqual(instance.commit_id, 'b' * 40)

        # Check values in DB
        db_instance = OpenEdXInstance.objects.get(pk=instance.pk)
        self.assertEqual(db_instance.commit_id, 'a' * 40)
示例#6
0
    def test_set_to_branch_tip_no_commit(self, mock_get_commit_id_from_ref):
        """
        Set the commit id to the tip of the current branch, with commit=False
        """
        mock_get_commit_id_from_ref.return_value = 'b' * 40
        instance = OpenEdXInstanceFactory(commit_id='a' * 40)
        instance.set_to_branch_tip(commit=False)
        self.assertEqual(instance.commit_id, 'b' * 40)

        # Check values in DB
        db_instance = OpenEdXInstance.objects.get(pk=instance.pk)
        self.assertEqual(db_instance.commit_id, 'a' * 40)
示例#7
0
    def test_set_to_branch_tip_commit(self, mock_get_commit_id_from_ref):
        """
        Set the commit id to the tip of the current branch, using the default commit policy (True)
        """
        mock_get_commit_id_from_ref.return_value = 'b' * 40
        instance = OpenEdXInstanceFactory(
            github_organization_name='org3',
            github_repository_name='repo3',
            commit_id='a' * 40,
        )
        instance.set_to_branch_tip()
        self.assertEqual(instance.commit_id, 'b' * 40)
        self.assertEqual(mock_get_commit_id_from_ref.mock_calls, [
            call('org3/repo3', 'master', ref_type='heads'),
        ])

        # Check values in DB
        db_instance = OpenEdXInstance.objects.get(pk=instance.pk)
        self.assertEqual(db_instance.commit_id, 'b' * 40)
示例#8
0
    def test_set_to_branch_tip_commit(self, mock_get_commit_id_from_ref):
        """
        Set the commit id to the tip of the current branch, using the default commit policy (True)
        """
        mock_get_commit_id_from_ref.return_value = 'b' * 40
        instance = OpenEdXInstanceFactory(
            github_organization_name='org3',
            github_repository_name='repo3',
            commit_id='a' * 40,
        )
        instance.set_to_branch_tip()
        self.assertEqual(instance.commit_id, 'b' * 40)
        self.assertEqual(mock_get_commit_id_from_ref.mock_calls, [
            call('org3/repo3', 'master', ref_type='heads'),
        ])

        # Check values in DB
        db_instance = OpenEdXInstance.objects.get(pk=instance.pk)
        self.assertEqual(db_instance.commit_id, 'b' * 40)