Beispiel #1
0
 def test_pull_raising_exception(self, fake_lib):
     fake_lib.LibError = LibError
     fake_lib.Repository.return_value.pull.side_effect = LibError
     step = Pull()
     with self.assertRaises(PulpCodedException) as assertion:
         step._pull('', '', '', 0)
         self.assertEqual(assertion.exception.error_code, errors.OST0002)
Beispiel #2
0
 def test_pull_raising_exception(self, fake_lib):
     fake_lib.LibError = LibError
     fake_lib.Repository.return_value.pull.side_effect = LibError
     try:
         step = Pull()
         step._pull('', '', '', 0)
         self.assertTrue(False, msg='Pull exception expected')
     except PulpCodedException, pe:
         self.assertEqual(pe.error_code, errors.OST0002)
Beispiel #3
0
 def test_pull_raising_exception(self, fake_lib):
     fake_lib.LibError = LibError
     fake_lib.Repository.return_value.pull.side_effect = LibError
     try:
         step = Pull()
         step._pull('', '', '')
         self.assertTrue(False, msg='Pull exception expected')
     except PulpCodedException, pe:
         self.assertEqual(pe.error_code, errors.OST0002)
Beispiel #4
0
    def test_process_main(self):
        repo_id = 'repo-xyz'
        path = 'root/path-123'
        branches = ['branch-1', 'branch-2']

        # test
        step = Pull()
        step.parent = Mock(storage_dir=path, repo_id=repo_id, branches=branches)
        step._pull = Mock()
        step.process_main()

        # validation
        step._pull.assert_called_once_with(path, repo_id, branches)
Beispiel #5
0
    def test_process_main(self):
        remote_id = 'remote-123'
        path = 'root/path-123'
        branches = ['branch-1', 'branch-2']

        # test
        step = Pull()
        step.parent = Mock(storage_path=path, remote_id=remote_id, branches=branches)
        step._pull = Mock()
        step.process_main()

        # validation
        self.assertEqual(
            step._pull.call_args_list,
            [
                ((path, remote_id, branches[0]), {}),
                ((path, remote_id, branches[1]), {}),
            ])
Beispiel #6
0
    def test_pull(self, fake_lib):
        remote_id = 'remote-123'
        path = 'root/path-123'
        branch = 'branch-1'
        repo = Mock()
        fake_lib.Repository.return_value = repo
        report = Mock(fetched=1, requested=2, percent=50)

        def fake_pull(remote_id, branch, listener):
            listener(report)

        repo.pull.side_effect = fake_pull

        # test
        step = Pull()
        step.report_progress = Mock()
        step._pull(path, remote_id, branch)

        # validation
        fake_lib.Repository.assert_called_once_with(path)
        repo.pull.assert_called_once_with(remote_id, [branch], ANY)
        step.report_progress.assert_called_with(force=True)
        self.assertEqual(step.progress_details, 'branch: branch-1 fetching 1/2 50%')
Beispiel #7
0
    def test_pull(self, fake_lib):
        remote_id = 'remote-123'
        path = 'root/path-123'
        branches = ['branch-1']
        repo = Mock()
        fake_lib.Repository.return_value = repo
        report = Mock(fetched=1, requested=2, percent=50)

        def fake_pull(remote_id, branch, listener):
            listener(report)

        repo.pull.side_effect = fake_pull

        # test
        step = Pull()
        step.report_progress = Mock()
        step._pull(path, remote_id, branches)

        # validation
        fake_lib.Repository.assert_called_once_with(path)
        repo.pull.assert_called_once_with(remote_id, branches, ANY)
        step.report_progress.assert_called_with(force=True)
        self.assertEqual(step.progress_details, 'fetching 1/2 50%')
Beispiel #8
0
    def test_process_main(self):
        repo_id = 'repo-xyz'
        path = 'root/path-123'
        branches = ['branch-1', 'branch-2']

        # test
        step = Pull()
        step.parent = Mock(storage_dir=path,
                           repo_id=repo_id,
                           branches=branches)
        step._pull = Mock()
        step.process_main()

        # validation
        step._pull.assert_called_once_with(path, repo_id, branches)
Beispiel #9
0
    def test_process_main(self):
        remote_id = 'remote-123'
        path = 'root/path-123'
        branches = ['branch-1', 'branch-2']

        # test
        step = Pull()
        step.parent = Mock(storage_path=path,
                           remote_id=remote_id,
                           branches=branches)
        step._pull = Mock()
        step.process_main()

        # validation
        self.assertEqual(step._pull.call_args_list, [
            ((path, remote_id, branches[0]), {}),
            ((path, remote_id, branches[1]), {}),
        ])
Beispiel #10
0
 def test_init(self):
     step = Pull()
     self.assertEqual(step.step_id, constants.IMPORT_STEP_PULL)
     self.assertTrue(step.description is not None)