def test_construct_requirements_txt(self): """Test construct requirements txt.""" pipfile_lock = PipfileLock.from_file(os.path.join(self.data_dir, "pipfiles", "Pipfile_requirements.lock")) assert ( pipfile_lock.construct_requirements_txt() == """# # This file is autogenerated by Thoth and is meant to be used with pip-compile # as provided by pip-tools. # --index-url https://pypi.org/simple --extra-index-url https://index-aicoe.a3c1.starter-us-west-1.openshiftapps.com/fedora28/1.9/jemalloc absl-py==0.5.0 \\ --hash=sha256:6fcc3c04dc881fd93d793674a42ee8c73155570eda8f8b90c4477c8522478b7b click==6.6 \\ --hash=sha256:cc6a19da8ebff6e7074f731447ef7e112bd23adf3de5c597cf9989f2fd8defe9 \\ --hash=sha256:fcf697e1fd4b567d817c69dab10a4035937fe6af175c05fd6806b69f74cbc6c4 python-dateutil==2.7.3; python_version >= '2.7' \\ --hash=sha256:1adb80e7a782c12e52ef9a8182bebeb73f1d7e24e374397af06fb4956c8dc5c0 \\ --hash=sha256:e27001de32f627c22380a688bcc43ce83504a7bc5da472209b4c70f02829f0b8 tensorflow==1.9.0rc0 \\ --hash=sha256:0588ac4f2b2e3994a5245c9be13a58e6128c26f7e6eb61c2ef90d82b58b78d4c \\ --hash=sha256:1a83b8e789a5b9bfdfc671d4368b976a8d9cc5d217209264cc987885ff55a6b1 \\ --hash=sha256:4dedb5dacd20df1e545835a40ad6b337fda11e32432bd643e4a8cd484d72fe0a # # dev packages # autopep8==1.4 \\ --hash=sha256:655e3ee8b4545be6cfed18985f581ee9ecc74a232550ee46e9797b6fbf4f336d """ )
def test_add_package_develop(self): """Test add package develop.""" pipfile = Pipfile.from_file( os.path.join(self.data_dir, "pipfiles", "Pipfile_test1")) pipfile_lock = PipfileLock.from_file( os.path.join(self.data_dir, "pipfiles", "Pipfile_test1.lock")) project = Project(pipfile=pipfile, pipfile_lock=pipfile_lock) source = Source(name="foo", url="https://foo.bar", verify_ssl=True, warehouse=False) assert "selinon" not in project.pipfile.dev_packages.packages with pytest.raises(InternalError): # Trying to add package with source but source is not present in the meta. project.add_package("selinon", "==1.0.0", develop=True, source=source) source = project.add_source(url="https://foo.bar") project.add_package("selinon", "==1.0.0", develop=True, source=source) assert "selinon" in project.pipfile.dev_packages.packages assert project.pipfile.dev_packages["selinon"].version == "==1.0.0" assert project.pipfile.dev_packages["selinon"].index.name == "foo-bar" assert project.pipfile.dev_packages["selinon"].develop is True # Do not add the package to the lock - lock has to be explicitly done. assert "selinon" not in project.pipfile_lock.dev_packages.packages
def test_add_package_develop(self): pipfile = Pipfile.from_file( os.path.join(self.data_dir, 'pipfiles', 'Pipfile_test1')) pipfile_lock = PipfileLock.from_file( os.path.join(self.data_dir, 'pipfiles', 'Pipfile_test1.lock')) project = Project(pipfile=pipfile, pipfile_lock=pipfile_lock) source = Source(name='foo', url='https://foo.bar', verify_ssl=True, warehouse=False) assert 'selinon' not in project.pipfile.dev_packages.packages with pytest.raises(InternalError): # Trying to add package with source but source is not present in the meta. project.add_package('selinon', '==1.0.0', develop=True, source=source) source = project.add_source(url='https://foo.bar') project.add_package('selinon', '==1.0.0', develop=True, source=source) assert 'selinon' in project.pipfile.dev_packages.packages assert project.pipfile.dev_packages['selinon'].version == '==1.0.0' assert project.pipfile.dev_packages['selinon'].index == 'foo-bar' assert project.pipfile.dev_packages['selinon'].develop is True # Do not add the package to the lock - lock has to be explicitly done. assert 'selinon' not in project.pipfile_lock.dev_packages.packages
def test_add_source(self): """Test add source.""" pipfile = Pipfile.from_file(os.path.join(self.data_dir, "pipfiles", "Pipfile_test1")) pipfile_lock = PipfileLock.from_file(os.path.join(self.data_dir, "pipfiles", "Pipfile_test1.lock")) project = Project(pipfile=pipfile, pipfile_lock=pipfile_lock) source = project.add_source(url="https://foo.bar") assert source.name is not None assert source.name in project.pipfile.meta.sources assert source is project.pipfile.meta.sources[source.name] assert source.name in project.pipfile_lock.meta.sources assert source is project.pipfile_lock.meta.sources[source.name]
def test_add_source(self): pipfile = Pipfile.from_file( os.path.join(self.data_dir, 'pipfiles', 'Pipfile_test1')) pipfile_lock = PipfileLock.from_file( os.path.join(self.data_dir, 'pipfiles', 'Pipfile_test1.lock')) project = Project(pipfile=pipfile, pipfile_lock=pipfile_lock) source = project.add_source(url='https://foo.bar') assert source.name is not None assert source.name in project.pipfile.meta.sources assert source is project.pipfile.meta.sources[source.name] assert source.name in project.pipfile_lock.meta.sources assert source is project.pipfile_lock.meta.sources[source.name]
def test_add_package(self): """Test add package.""" pipfile = Pipfile.from_file(os.path.join(self.data_dir, "pipfiles", "Pipfile_test1")) pipfile_lock = PipfileLock.from_file(os.path.join(self.data_dir, "pipfiles", "Pipfile_test1.lock")) project = Project(pipfile=pipfile, pipfile_lock=pipfile_lock) assert "selinon" not in project.pipfile.packages.packages project.add_package("selinon", "==1.0.0") assert "selinon" in project.pipfile.packages.packages assert project.pipfile.packages["selinon"].version == "==1.0.0" assert project.pipfile.packages["selinon"].index is None assert project.pipfile.packages["selinon"].develop is False # Do not add the package to the lock - lock has to be explicitly done. assert "selinon" not in project.pipfile_lock.packages.packages
def test_add_package(self): pipfile = Pipfile.from_file( os.path.join(self.data_dir, 'pipfiles', 'Pipfile_test1')) pipfile_lock = PipfileLock.from_file( os.path.join(self.data_dir, 'pipfiles', 'Pipfile_test1.lock')) project = Project(pipfile=pipfile, pipfile_lock=pipfile_lock) assert 'selinon' not in project.pipfile.packages.packages project.add_package('selinon', '==1.0.0') assert 'selinon' in project.pipfile.packages.packages assert project.pipfile.packages['selinon'].version == '==1.0.0' assert project.pipfile.packages['selinon'].index is None assert project.pipfile.packages['selinon'].develop is False # Do not add the package to the lock - lock has to be explicitly done. assert 'selinon' not in project.pipfile_lock.packages.packages
def test_extras_parsing(self): """Test extras parsing.""" pipfile_instance = Pipfile.from_file(os.path.join(self.data_dir, "pipfiles", "Pipfile_extras")) instance = PipfileLock.from_file( os.path.join(self.data_dir, "pipfiles", "Pipfile_extras.lock"), pipfile=pipfile_instance ) assert instance is not None assert len(instance.packages.packages) == 34 assert "selinon" in instance.packages.packages package_version = instance.packages.packages["selinon"] assert set(package_version.to_dict().pop("extras")) == { "celery", "mongodb", "postgresql", "redis", "s3", "sentry", } assert set(package_version.extras) == {"celery", "mongodb", "postgresql", "redis", "s3", "sentry"}
def test_construct_requirements_txt(self): pipfile_lock = PipfileLock.from_file( os.path.join(self.data_dir, 'pipfiles', 'Pipfile_requirements.lock')) assert pipfile_lock.construct_requirements_txt() == """#