def test_fail_to_upload_if_package_version_not_pep440_compliant(self): src_repo = os.path.join(THISDIR, 'generalized_package') with tempfile.TemporaryDirectory() as tmpdir: dst_repo = os.path.join(tmpdir, 'generalized_package') shutil.copytree(src_repo, dst_repo) rc = subprocess.run( ['python', 'setup.py', 'sdist'], check=True, cwd=dst_repo, env={ **os.environ, 'TEST_PACKAGE_NAME': self.pkg_name, # Version format does not follow PEP440 guidelines. # See https://peps.python.org/pep-0440 for more details 'TEST_PACKAGE_VERSION': '0.0.0-343-gea3bdad', }) print("sdist returned", rc) with self.assertRaises(out.VersionValidationError): out.out( os.path.join(dst_repo, "dist"), { 'source': { 'name': self.pkg_name, 'repository': make_input(None)['source']['repository'] }, 'params': { 'glob': '*.tar.gz' } })
def test_upload_pypi(self): rc = subprocess.run(['python', 'setup.py', 'sdist'], check=True, cwd=REPODIR) print("sdist returned", rc) out.out( os.path.join(REPODIR, 'dist'), { 'source': {'test': True, 'name': 'concourse-pypi-resource'}, 'params': {'glob': '*.tar.gz'} } )
def test_fail_to_upload_if_input_name_different_from_package_name(self): rc = subprocess.run(['python', 'setup.py', 'sdist'], check=True, cwd=REPODIR) print("sdist returned", rc) with self.assertRaises(out.NamesValidationError) as context: out.out( os.path.join(REPODIR, 'dist'), { 'source': {'test': True, 'name': 'mismatching-name'}, 'params': {'glob': '*.tar.gz'} } )
def setUpClass(cls): super(TestCheck, cls).setUpClass() # upload the test-set src = os.path.join(THISDIR, 'test_dist') for fn in os.listdir(src): out.out(src, { 'source': make_input(None)['source'], 'params': { 'glob': fn } })
def test_upload_package_with_local_identifier(self): # Format: <public version identifier>[+<local version label>] # See https://peps.python.org/pep-0440 for more details version = '1.2.3.dev10+g123abc45' src_repo = os.path.join(THISDIR, 'generalized_package') with tempfile.TemporaryDirectory() as tmpdir: dst_repo = os.path.join(tmpdir, 'generalized_package') shutil.copytree(src_repo, dst_repo) rc = subprocess.run( ['python', 'setup.py', 'sdist'], check=True, cwd=dst_repo, env={ **os.environ, 'TEST_PACKAGE_NAME': self.pkg_name, 'TEST_PACKAGE_VERSION': version, }) print("sdist returned", rc) output = out.out( os.path.join(dst_repo, "dist"), { 'source': { 'name': self.pkg_name, 'repository': make_input(None)['source']['repository'], }, 'params': { 'glob': '*.tar.gz' } }) assert output['version']['version'] == version
def test_fail_to_upload_if_package_version_not_pep440_compliant(self): rc = subprocess.run(['python', 'setup.py', 'sdist'], check=True, cwd=os.path.join(THISDIR, 'generalized_package'), env={ **os.environ, 'TEST_PACKAGE_NAME': 'test_package1', 'TEST_PACKAGE_VERSION': '0.0.0-343-gea3bdad', } ) print("sdist returned", rc) with self.assertRaises(out.VersionValidationError): out.out( os.path.join(THISDIR, 'generalized_package/dist'), { 'source': {'test': True, 'name': 'test_package1', 'repository': {'username': '******', 'password': '******'}}, 'params': {'glob': '*.tar.gz'} } )