def test_bundle_calls_tarfile_open_with_correct_arguments(self):
     archive_name = '{}{}.tgz'.format(self.fake_target_name,
                                      self.fake_bundle_name)
     job_source_bundle = JobSourceBundle(self.fake_bundle_name,
                                         self.fake_target_name)
     job_source_bundle.bundle()
     self.mock_tarfile_open.assert_called_with(archive_name, 'w:gz')
 def test_bundle_add_to_tarfile(self):
     mock_tar = self.MockFileContextManager()
     self.mock_tarfile_open.return_value = mock_tar
     job_source_bundle = JobSourceBundle(self.fake_bundle_name,
                                         self.fake_target_name)
     job_source_bundle.bundle()
     mock_tar.add.assert_called_with('.')
 def test_unbundle_extracts_from_tarfile(self):
     mock_tar = self.MockFileContextManager()
     self.mock_tarfile_open.return_value = mock_tar
     job_source_bundle = JobSourceBundle(self.fake_bundle_name,
                                         self.fake_target_name)
     job_source_bundle.unbundle('../')
     mock_tar.extractall.assert_called()
 def test_unbundle_calls_mkpath_with_correct_arguments(self):
     mock_tar = self.MockFileContextManager()
     self.mock_tarfile_open.return_value = mock_tar
     job_source_bundle = JobSourceBundle(self.fake_bundle_name,
                                         self.fake_target_name)
     job_source_bundle.unbundle('../')
     self.mock_mkpath.assert_called_with('../')
 def test_cleanup_calls_remove_when_job_archive_exists(self):
     self.mock_os_exists.return_value = True
     job_source_bundle = JobSourceBundle(self.fake_bundle_name,
                                         self.fake_target_name)
     job_source_bundle.cleanup()
     self.mock_os_remove.assert_called_with('{}{}.tgz'.format(
         self.fake_target_name, self.fake_bundle_name))
    def test_from_dict_creates_job_source_bundle(self, mock_job_source_bundle):
        job_dict = {
            'bundle_name': self.fake_bundle_name,
            'target_path': self.fake_target_name
        }
        JobSourceBundle.from_dict(job_dict)

        mock_job_source_bundle.assert_called_with(self.fake_bundle_name,
                                                  self.fake_target_name)
 def test_file_listing_calls_tarfile_open_with_correct_arguments(self):
     mock_tar = self.MockTarWithFiles()
     self.mock_tarfile_open.return_value = mock_tar
     archive_name = '{}{}.tgz'.format(self.fake_target_name,
                                      self.fake_bundle_name)
     job_source_bundle = JobSourceBundle(self.fake_bundle_name,
                                         self.fake_target_name)
     some_var = job_source_bundle.file_listing()
     next(some_var)
     self.mock_tarfile_open.assert_called_with(archive_name, 'r:gz')
 def test_from_dict_returns_job_source_bundle(self):
     job_dict = {
         'bundle_name': self.fake_bundle_name,
         'target_path': self.fake_target_name
     }
     self.assertIsInstance(JobSourceBundle.from_dict(job_dict),
                           JobSourceBundle)
Beispiel #9
0
    def _create_deployment(self, job_name, job):
        from foundations_contrib.job_source_bundle import JobSourceBundle

        deployment_constructor, constructor_args, constructor_kwargs = self._deployment_constructor_and_args_and_kwargs()

        job_source_bundle = JobSourceBundle.for_deployment()

        return deployment_constructor(job_name, job, job_source_bundle, *constructor_args, **constructor_kwargs)
Beispiel #10
0
    def _make_deployment(self, stage, **kwargs):
        from foundations import Job
        from foundations_contrib.job_source_bundle import JobSourceBundle
        from foundations_contrib.bucket_job_deployment import BucketJobDeployment
        from uuid import uuid4
        from integration.config import make_code_bucket, make_result_bucket

        job = Job(stage, **kwargs)
        job_name = str(uuid4())
        source_bundle = JobSourceBundle.for_deployment()

        return BucketJobDeployment(job_name, job, source_bundle,
                                   make_code_bucket(), make_result_bucket())
 def test_for_deployment_returns_job_source_bundle(self):
     self.assertIsInstance(JobSourceBundle.for_deployment(),
                           JobSourceBundle)
 def test_for_deployment_creates_job_source_bundle_with_correct_arguments(
         self, mock_job_source_bundle):
     self.mock_uuid4.return_value = self.fake_uuid
     JobSourceBundle.for_deployment()
     mock_job_source_bundle.assert_called_with(self.fake_uuid,
                                               self.temp_directory + '/')
 def test_cleanup_does_not_calls_remove_when_job_archive_exists(self):
     self.mock_os_exists.return_value = False
     job_source_bundle = JobSourceBundle(self.fake_bundle_name,
                                         self.fake_target_name)
     job_source_bundle.cleanup()
     self.mock_os_remove.assert_not_called()
 def test_cleanup_checks_job_archive_exists(self):
     job_source_bundle = JobSourceBundle(self.fake_bundle_name,
                                         self.fake_target_name)
     job_source_bundle.cleanup()
     self.mock_os_exists.assert_called_with('{}{}.tgz'.format(
         self.fake_target_name, self.fake_bundle_name))
 def test_job_archive_returns_job_archive(self):
     job_source_bundle = JobSourceBundle(self.fake_bundle_name,
                                         self.fake_target_name)
     self.assertEqual(
         job_source_bundle.job_archive(),
         '{}{}.tgz'.format(self.fake_target_name, self.fake_bundle_name))