Пример #1
0
 def test_customize_tests_run_on_fork_if_no_remote(self, mock_etree,
                                                   mock_open, mock_rmtree,
                                                   mock_libvirt, mock_repo,
                                                   mock_git):
     self.create_user_with_role(self.user.name, self.user.email,
                                self.user.password, Role.tester)
     self.create_forktest("own-fork-commit", TestPlatform.linux)
     import mod_ci.cron
     import mod_ci.controllers
     reload(mod_ci.cron)
     reload(mod_ci.controllers)
     from mod_ci.cron import cron
     conn = mock_libvirt()
     vm = conn.lookupByName()
     import libvirt
     # mocking the libvirt kvm to shut down
     vm.info.return_value = [libvirt.VIR_DOMAIN_SHUTOFF]
     # Setting current snapshot of libvirt
     vm.hasCurrentSnapshot.return_value = 1
     repo = mock_repo()
     origin = repo.create_remote()
     from collections import namedtuple
     GitPullInfo = namedtuple('GitPullInfo', 'flags')
     pull_info = GitPullInfo(flags=0)
     origin.pull.return_value = [pull_info]
     cron()
     fork_url = ('https://github.com/{user}/{repo}.git').format(
         user=self.user.name, repo=g.github['repository'])
     repo.create_remote.assert_called_with('fork_2', url=fork_url)
     repo.create_head.assert_called_with('CI_Branch', origin.refs.master)
Пример #2
0
 def test_customize_tests_run_on_selected_regression_tests(
         self, mock_etree, mock_open, mock_rmtree, mock_libvirt, mock_repo,
         mock_git):
     self.create_user_with_role(self.user.name, self.user.email,
                                self.user.password, Role.tester)
     self.create_forktest("own-fork-commit",
                          TestPlatform.linux,
                          regression_tests=[2])
     import mod_ci.cron
     import mod_ci.controllers
     reload(mod_ci.cron)
     reload(mod_ci.controllers)
     from mod_ci.cron import cron
     conn = mock_libvirt()
     vm = conn.lookupByName()
     import libvirt
     vm.info.return_value = [libvirt.VIR_DOMAIN_SHUTOFF]
     vm.hasCurrentSnapshot.return_value = 1
     repo = mock_repo()
     origin = repo.remote()
     from collections import namedtuple
     Remotes = namedtuple('Remotes', 'name')
     repo.remotes = [Remotes(name='fork_2')]
     GitPullInfo = namedtuple('GitPullInfo', 'flags')
     pull_info = GitPullInfo(flags=0)
     origin.pull.return_value = [pull_info]
     single_test = mock_etree.Element('tests')
     mock_etree.Element.return_value = single_test
     cron()
     mock_etree.SubElement.assert_any_call(single_test, 'entry', id=str(2))
     assert (single_test, 'entry', str(1)) not in mock_etree.call_args_list
Пример #3
0
 def test_customize_tests_run_on_fork_if_remote_exist(
         self, mock_etree, mock_open, mock_rmtree, mock_libvirt, mock_repo,
         mock_git):
     self.create_user_with_role(self.user.name, self.user.email,
                                self.user.password, Role.tester)
     self.create_forktest("own-fork-commit", TestPlatform.linux)
     import mod_ci.cron
     import mod_ci.controllers
     reload(mod_ci.cron)
     reload(mod_ci.controllers)
     from mod_ci.cron import cron
     conn = mock_libvirt()
     vm = conn.lookupByName()
     import libvirt
     # mocking the libvirt kvm to shut down
     vm.info.return_value = [libvirt.VIR_DOMAIN_SHUTOFF]
     # Setting current snapshot of libvirt
     vm.hasCurrentSnapshot.return_value = 1
     repo = mock_repo()
     origin = repo.remote()
     from collections import namedtuple
     Remotes = namedtuple('Remotes', 'name')
     repo.remotes = [Remotes(name='fork_2')]
     GitPullInfo = namedtuple('GitPullInfo', 'flags')
     pull_info = GitPullInfo(flags=0)
     origin.pull.return_value = [pull_info]
     cron()
     repo.remote.assert_called_with('fork_2')
 def test_customize_tests_run_on_fork_if_no_remote(self, mock_etree, mock_open,
                                                   mock_rmtree, mock_libvirt, mock_repo, mock_git):
     self.create_user_with_role(
         self.user.name, self.user.email, self.user.password, Role.tester)
     self.create_forktest("own-fork-commit", TestPlatform.linux)
     import mod_ci.cron
     import mod_ci.controllers
     reload(mod_ci.cron)
     reload(mod_ci.controllers)
     from mod_ci.cron import cron
     conn = mock_libvirt()
     vm = conn.lookupByName()
     import libvirt
     # mocking the libvirt kvm to shut down
     vm.info.return_value = [libvirt.VIR_DOMAIN_SHUTOFF]
     # Setting current snapshot of libvirt
     vm.hasCurrentSnapshot.return_value = 1
     repo = mock_repo()
     origin = repo.create_remote()
     from collections import namedtuple
     GitPullInfo = namedtuple('GitPullInfo', 'flags')
     pull_info = GitPullInfo(flags=0)
     origin.pull.return_value = [pull_info]
     cron()
     fork_url = 'https://github.com/{user}/{repo}.git'.format(user=self.user.name, repo=g.github['repository'])
     repo.create_remote.assert_called_with('fork_2', url=fork_url)
     repo.create_head.assert_called_with('CI_Branch', origin.refs.master)
 def test_customize_tests_run_on_selected_regression_tests(self, mock_etree, mock_open,
                                                           mock_rmtree, mock_libvirt, mock_repo, mock_git):
     self.create_user_with_role(
         self.user.name, self.user.email, self.user.password, Role.tester)
     self.create_forktest("own-fork-commit", TestPlatform.linux, regression_tests=[2])
     import mod_ci.cron
     import mod_ci.controllers
     reload(mod_ci.cron)
     reload(mod_ci.controllers)
     from mod_ci.cron import cron
     conn = mock_libvirt()
     vm = conn.lookupByName()
     import libvirt
     vm.info.return_value = [libvirt.VIR_DOMAIN_SHUTOFF]
     vm.hasCurrentSnapshot.return_value = 1
     repo = mock_repo()
     origin = repo.remote()
     from collections import namedtuple
     Remotes = namedtuple('Remotes', 'name')
     repo.remotes = [Remotes(name='fork_2')]
     GitPullInfo = namedtuple('GitPullInfo', 'flags')
     pull_info = GitPullInfo(flags=0)
     origin.pull.return_value = [pull_info]
     single_test = mock_etree.Element('tests')
     mock_etree.Element.return_value = single_test
     cron()
     mock_etree.SubElement.assert_any_call(single_test, 'entry', id=str(2))
     assert (single_test, 'entry', str(1)) not in mock_etree.call_args_list
 def test_customize_tests_run_on_fork_if_remote_exist(self, mock_etree, mock_open,
                                                      mock_rmtree, mock_libvirt, mock_repo, mock_git):
     self.create_user_with_role(self.user.name, self.user.email, self.user.password, Role.tester)
     self.create_forktest("own-fork-commit", TestPlatform.linux)
     import mod_ci.cron
     import mod_ci.controllers
     reload(mod_ci.cron)
     reload(mod_ci.controllers)
     from mod_ci.cron import cron
     conn = mock_libvirt()
     vm = conn.lookupByName()
     import libvirt
     # mocking the libvirt kvm to shut down
     vm.info.return_value = [libvirt.VIR_DOMAIN_SHUTOFF]
     # Setting current snapshot of libvirt
     vm.hasCurrentSnapshot.return_value = 1
     repo = mock_repo()
     origin = repo.remote()
     from collections import namedtuple
     Remotes = namedtuple('Remotes', 'name')
     repo.remotes = [Remotes(name='fork_2')]
     GitPullInfo = namedtuple('GitPullInfo', 'flags')
     pull_info = GitPullInfo(flags=0)
     origin.pull.return_value = [pull_info]
     cron()
     repo.remote.assert_called_with('fork_2')