def test_pack_two_packages_in_specific_dir(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) options = parser.parse_args(['pack', 'something', 'another_thing', '--output-dir', 'wheel_directory']) self.assertTrue(hasattr(options, 'command')) self.assertTrue(callable(options.command))
def test_install_two_packages(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) with util.temporary_directory(prefix='glyco-install-test-') as tempdir: options = parser.parse_args(['pack', os.path.join(DATA_DIR, 'source_package'), os.path.join(DATA_DIR, 'installed_package'), '--output-dir', tempdir]) self.assertFalse(pack.pack(options)) wheel_paths = [os.path.join(tempdir, whl) for whl in os.listdir(tempdir)] options = parser.parse_args( ['install', wheel_paths[0], wheel_paths[1], '--install-dir', os.path.join(tempdir, 'local')]) install.install(options) self.assertTrue(os.path.isdir( os.path.join(tempdir, 'local', 'source_package'))) # Make sure the directory is not empty. self.assertTrue( len(os.listdir(os.path.join(tempdir, 'local', 'source_package'))) > 0) self.assertTrue(os.path.isdir( os.path.join(tempdir, 'local', 'source_package-0.0.1.dist-info'))) self.assertTrue(os.path.isdir( os.path.join(tempdir, 'local', 'installed_package'))) self.assertTrue( len(os.listdir( os.path.join(tempdir, 'local', 'installed_package'))) > 0) self.assertTrue(os.path.isdir( os.path.join(tempdir, 'local', 'installed_package-0.0.1.dist-info')))
def test_install_two_packages(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) options = parser.parse_args(['install', 'package_name.whl', 'package2_name.whl', '-i', 'nice-dir2']) self.assertTrue(hasattr(options, 'command')) self.assertTrue(callable(options.command))
def test_pack_two_packages_in_specific_dir(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) options = parser.parse_args([ 'pack', 'something', 'another_thing', '--output-dir', 'wheel_directory' ]) self.assertTrue(hasattr(options, 'command')) self.assertTrue(callable(options.command))
def test_pack_unhandled(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) with util.temporary_directory('glyco-pack-test-') as tempdir: # DATA_DIR is not a package at all. options = parser.parse_args(['pack', DATA_DIR, '--output-dir', tempdir]) self.assertTrue(pack.pack(options)) self.assertEqual(len(os.listdir(tempdir)), 0)
def test_pack_unhandled(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) with util.temporary_directory('glyco-pack-test-') as tempdir: # DATA_DIR is not a package at all. options = parser.parse_args( ['pack', DATA_DIR, '--output-dir', tempdir]) self.assertTrue(pack.pack(options)) self.assertEqual(len(os.listdir(tempdir)), 0)
def test_pack(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) with util.temporary_directory(prefix='glyco-pack-test-') as tempdir: options = parser.parse_args(['pack', os.path.join(DATA_DIR, 'source_package'), os.path.join(DATA_DIR, 'installed_package'), '--output-dir', tempdir]) # False is turned into the 0 (success) return code. self.assertFalse(pack.pack(options)) self.assertEqual(len(os.listdir(tempdir)), 2)
def test_pack_partly_unhandled(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) with util.temporary_directory('glyco-pack-test-') as tempdir: options = parser.parse_args(['pack', DATA_DIR, os.path.join(DATA_DIR, 'source_package'), '--output-dir', tempdir]) self.assertTrue(pack.pack(options)) # We should not have generated any wheel. self.assertEqual(len(os.listdir(tempdir)), 0)
def test_pack(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) with util.temporary_directory(prefix='glyco-pack-test-') as tempdir: options = parser.parse_args([ 'pack', os.path.join(DATA_DIR, 'source_package'), os.path.join(DATA_DIR, 'installed_package'), '--output-dir', tempdir ]) # False is turned into the 0 (success) return code. self.assertFalse(pack.pack(options)) self.assertEqual(len(os.listdir(tempdir)), 2)
def test_pack_partly_unhandled(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) with util.temporary_directory('glyco-pack-test-') as tempdir: options = parser.parse_args([ 'pack', DATA_DIR, os.path.join(DATA_DIR, 'source_package'), '--output-dir', tempdir ]) self.assertTrue(pack.pack(options)) # We should not have generated any wheel. self.assertEqual(len(os.listdir(tempdir)), 0)
def test_install_invalid_hash(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) with util.temporary_directory(prefix='glyco-install-test-') as tempdir: options = parser.parse_args([ 'install', os.path.join( DATA_DIR, 'wheels', 'source_package_invalid_sha1-0.0.1-0_' + 'deadbeef3767ced3ec53b89b297e0268f1338b2b-py2-none-any.whl'), '--install-dir', os.path.join(tempdir, 'local')]) result = install.install(options) self.assertNotEqual(result, 0)
def test_pack_two_packages(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) options = parser.parse_args(['pack', 'something', 'another_thing']) self.assertTrue(hasattr(options, 'command')) self.assertTrue(callable(options.command))
def test_install_zero_packages(self): parser = argparse.ArgumentParser() main_.add_argparse_options(parser) options = parser.parse_args(['install']) self.assertTrue(hasattr(options, 'command')) self.assertTrue(callable(options.command))