def test_extract_package_exception(self):
        parser = Parser(self._get_parser_data())
        download = Download(self.get_git_download_data())

        job = JobBuilder(parser, download)

        with pytest.raises(Exception) as inst:
            job.extract_package(os.path.join('/tmp', self.FILENAME))
        assert str(inst.value) == "It was not possible to extract the package because the file /tmp/build-composer-cc2632fae2cab2f73ce6e6607d9b0befec0b82a1.tar.gz doesn't exists."
    def test_get_git_abstract_project(self):
        parser = Parser(self._get_parser_data())

        download = Download(self.get_git_download_data())
        download.get_archieve = Mock(
            return_value="/tmp/unitests/build-composer-cc2632fae2cab2f73ce6e6607d9b0befec0b82a1.tar.gz")
        job = JobBuilder(parser, download)
        file = job.get_git_abstract_project(parser)

        assert file is "/tmp/unitests/build-composer-cc2632fae2cab2f73ce6e6607d9b0befec0b82a1.tar.gz"
    def test_extract_package(self):
        parser = Parser(self._get_parser_data())
        download = Download(self.get_git_download_data())

        job = JobBuilder(parser, download)

        directory = self.prepare_fixture(parser.get_name())
        job.extract_package(os.path.join(directory, self.FILENAME))

        assert os.path.isdir(os.path.join(self.directory, parser.get_abstract_name() + ".git")) is True
        self.remove_fixture()
    def test_pre_process_configuration(self):
        parser = Parser(self._get_parser_data())
        download = Download(self.get_git_download_data())

        job = JobBuilder(parser, download)

        directory = self.prepare_fixture(parser.get_name())
        folder = job.extract_package(os.path.join(directory, self.FILENAME))

        job.pre_process_configuration(folder)

        assert os.path.isfile(os.path.join(self.directory, parser.get_abstract_name() + ".git/output.xml")) is True
 def __job_builder(self, jobs_data):
     """
     Create job
     :param jobs_data:
     :param pipeline:
     :return:
     """
     download = self.get_download_instance()
     for job_data in jobs_data['jobs']:
         job_parser = Parser(job_data)
         job = JobBuilder(job_parser, download)
         job.process()
         self.pipeline.add_job(job)