Example #1
0
 def test_pass_find_all_versions(self):
     findable_versions = [
         {
             'alice.apache': '*',
             'gunjan.gunicorn': '!=1.2.3',
             'gunjan.gnu_app': '3.0.0',
         },
         {
             'alice.apache': '^1.0',
             'gunjan.gunicorn': '^1.1',
         },
         {
             'alice.apache': '>0.9.1',
             'gunjan.gunicorn': '1.2.3',
         },
         {
             'gunjan.gunicorn': '1.2.3',
             'alice.apache': '>0.9.1',
         },
         {},
         {'alice.apache': '1.0.0'},
         {'gunjan.gunicorn': '1.2.4'},
         {'gunjan.gunicorn': '>=1.0.0,<=2.0.0'},
         {'gunjan.gunicorn': '>=1.0.0,!=1.0.5'},
     ]
     for dep in findable_versions:
         self.metadata['dependencies'] = dep
         collection_info = GalaxyCollectionInfo(**self.metadata)
         check_dependencies(collection_info)
         assert isinstance(collection_info, GalaxyCollectionInfo)
Example #2
0
 def test_pass_find_all_versions(self):
     findable_versions = [
         {
             'alice.apache': '*',
             'gunjan.gunicorn': '!=1.2.3',
             'gunjan.gnu_app': '3.0.0',
         },
         {
             'gunjan.gunicorn': '^1.1',
         },
         {
             'alice.apache': '>0.9.1',
             'gunjan.gunicorn': '1.2.3',
         },
         {
             'gunjan.gunicorn': '1.2.3',
             'alice.apache': '>0.9.1',
         },
         {},
         {
             'gunjan.gunicorn': '1.2.4'
         },
         {
             'gunjan.gunicorn': '>=1.0.0,<=2.0.0'
         },
         {
             'gunjan.gunicorn': '>=1.0.0,!=1.0.5'
         },
     ]
     for dep in findable_versions:
         check_dependencies(dep)
Example #3
0
def _process_collection(artifact, filename, task_logger):
    with tempfile.TemporaryDirectory() as extract_dir:
        with artifact.file.open() as pkg_file, \
                tarfile.open(fileobj=pkg_file) as pkg_tar:
            pkg_tar.extractall(extract_dir)

        try:
            importer_obj = importer.import_collection(extract_dir, filename,
                                                      task_logger)
        except i_exc.ImporterError as e:
            raise exc.ImportFailed(str(e))

        check_dependencies(importer_obj.collection_info)

    _log_importer_results(importer_obj)
    return importer_obj
Example #4
0
 def test_fail_on_unfound_version(self):
     at_least_one_missing = [
         {
             'alice.apache': '1.0.1'
         },
         {
             'alice.apache': '!=1.0.0'
         },
         {
             'gunjan.gunicorn': '^1.5'
         },
         {
             'alice.apache': '~1'
         },  # semantic_version error
         {
             'alice.apache': '2',
             'gunjan.gunicorn': '<1.2.3',
         },
         {
             'gunjan.gunicorn': '<1.2.3',
             'alice.apache': '2',
         },
         {
             'alice.apache': '1.0.0',  # findable
             'gunjan.gunicorn': '1.5',
         },
         {
             'gunjan.gunicorn': '1.5',
             'alice.apache': '1.0.0',  # findable
         },
         {
             'gunjan.gunicorn': '1.2.4',  # findable
             'gunjan.gnu_app': '3.0.0',  # findable
             'alice.apache': '>1.0.0',
         },
         {
             'gunjan.gunicorn': '1.2.4',  # findable
             'alice.apache': '>1.0.0',
             'gunjan.gnu_app': '3.0.0',  # findable
         },
     ]
     for dep in at_least_one_missing:
         self.metadata['dependencies'] = dep
         collection_info = GalaxyCollectionInfo(**self.metadata)
         with pytest.raises(ImportFailed) as exc:
             check_dependencies(collection_info)
         assert 'no matching version found' in str(exc)
Example #5
0
def _process_collection(artifact, filename, task_logger):
    try:
        with artifact.file.open() as artifact_file:
            importer_data = process_collection(artifact_file,
                                               filename=filename,
                                               logger=task_logger)
    except ImporterError as e:
        log.error(f'Collection processing was not successfull: {e}')
        raise
    task_logger.info('Processing via galaxy-importer complete')

    importer_data = _transform_importer_data(importer_data)

    task_logger.info('Checking dependencies in importer data')
    check_dependencies(importer_data['metadata']['dependencies'])

    return importer_data
Example #6
0
 def test_fail_on_unfound_version(self):
     at_least_one_missing = [
         {
             'alice.apache': '1.0.1'
         },
         {
             'alice.apache': '!=1.0.0'
         },
         {
             'gunjan.gunicorn': '^1.5'
         },
         {
             'alice.apache': '~1'
         },
         {
             'alice.apache': '2',
             'gunjan.gunicorn': '<1.2.3',
         },
         {
             'gunjan.gunicorn': '<1.2.3',
             'alice.apache': '2',
         },
         {
             'alice.apache': '1.0.0',  # findable
             'gunjan.gunicorn': '1.5',
         },
         {
             'gunjan.gunicorn': '1.5',
             'alice.apache': '1.0.0',  # findable
         },
         {
             'gunjan.gunicorn': '1.2.4',  # findable
             'gunjan.gnu_app': '3.0.0',  # findable
             'alice.apache': '>1.0.0',
         },
         {
             'gunjan.gunicorn': '1.2.4',  # findable
             'alice.apache': '>1.0.0',
             'gunjan.gnu_app': '3.0.0',  # findable
         },
     ]
     for dep in at_least_one_missing:
         with pytest.raises(ImportFailed) as exc:
             check_dependencies(dep)
         assert 'no matching version found' in str(exc)
Example #7
0
 def test_dep_cannot_find_col(self):
     at_least_one_missing = [
         {
             'alice.php': '1.2.3',
         },
         {
             'alice.apache': '*',
             'alice.php': '1.2.3',
         },
         {
             'alice.apache': '*',
             'gunjan.gnu_app': '3.0.0',
             'gunjan.doesnotexist': '9.9.9',
         },
     ]
     for dep in at_least_one_missing:
         with pytest.raises(ImportFailed) as exc:
             check_dependencies(dep)
         assert 'collection not in galaxy' in str(exc)
Example #8
0
 def test_dep_cannot_find_ns(self):
     at_least_one_missing = [
         {
             'ned.nginx': '1.2.3',
         },
         {
             'dne.nginx': '9.9.9',
             'ned.nginx': '1.2.3',
             'alice.apache': '*',
         },
         {
             'alice.apache': '*',
             'gunjan.gnu_app': '3.0.0',
             'dne.nginx': '9.9.9',
         },
     ]
     for dep in at_least_one_missing:
         with pytest.raises(ImportFailed) as exc:
             check_dependencies(dep)
         assert 'namespace not in galaxy' in str(exc)
Example #9
0
 def test_dep_cannot_find_ns(self):
     at_least_one_missing = [
         {
             'ned.nginx': '1.2.3',
         },
         {
             'dne.nginx': '9.9.9',
             'ned.nginx': '1.2.3',
             'alice.apache': '*',
         },
         {
             'alice.apache': '*',
             'gunjan.gnu_app': '3.0.0',
             'dne.nginx': '9.9.9',
         },
     ]
     for dep in at_least_one_missing:
         self.metadata['dependencies'] = dep
         collection_info = GalaxyCollectionInfo(**self.metadata)
         with pytest.raises(ImportFailed) as exc:
             check_dependencies(collection_info)
         assert 'namespace not in galaxy' in str(exc)