def setUp(self): self.packer = Packer() self.config = PackagePackOptions()
class PackagePackerTest(unittest.TestCase): def setUp(self): self.packer = Packer() self.config = PackagePackOptions() def tearDown(self): with fake_project(): self.packer.do(['rm', 'README.rst']) self.packer.do(['rm', 'LICENSE']) self.packer.do(['rmdir', 'docs']) def test_do(self): self.packer.do(['touch', 'test_file.tmp']) self.assertTrue(os.path.exists('test_file.tmp')) self.packer.do(['rm', 'test_file.tmp']) self.assertFalse(os.path.exists('test_file.tmp')) def test_pack_fails_on_no_README_or_no_LICENSE(self): with fake_project(): self.config.parseOptions() self.assertRaises( usage.UsageError, self.packer.pack_application, 'sdist', self.config, config.Application('config/application.json') ) def test_pack_fails_on_no_docs_directory(self): with self._generate_README_and_LICENSE(): self.config.parseOptions() self.assertRaises( usage.UsageError, self.packer.pack_application, 'sdist', self.config, config.Application('config/application.json') ) self.assertTrue(os.path.exists('README.rst')) self.assertTrue(os.path.exists('LICENSE')) self.assertFalse(os.path.exists('docs')) @defer.inlineCallbacks def test_pack_sdist(self): result = yield utils.getProcessValue('mamba-admin', [], os.environ) if result == 1: raise unittest.SkipTest('mamba framework is not installed yet') with self._generate_docs(): self.config.parseOptions() self.config['name'] = 'mamba-dummy' self.packer.pack_application( 'sdist', self.config, config.Application('config/application.json') ) self.assertTrue(os.path.exists('mamba-dummy-0.1.2.tar.gz')) self.packer.do(['rm', 'mamba-dummy-0.1.2.tar.gz']) @defer.inlineCallbacks def test_pack_egg(self): result = yield utils.getProcessValue('mamba-admin', [], os.environ) if result == 1: raise unittest.SkipTest('mamba framework is not installed yet') with self._generate_docs(): self.config.parseOptions() self.config['name'] = 'mamba-dummy' self.packer.pack_application( 'bdist_egg', self.config, config.Application('config/application.json') ) major, minor = sys.version_info[:2] self.assertTrue(os.path.exists( 'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor)) ) self.packer.do( ['rm', 'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor)] ) @defer.inlineCallbacks def test_is_mamba_package_for_egg_file(self): result = yield utils.getProcessValue('mamba-admin', [], os.environ) if result == 1: raise unittest.SkipTest('mamba framework is not installed yet') with self._generate_docs(): self.config.parseOptions() self.config['name'] = 'mamba-dummy' self.packer.pack_application( 'bdist_egg', self.config, config.Application('config/application.json') ) major, minor = sys.version_info[:2] self.assertTrue(os.path.exists( 'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor)) ) path = filepath.FilePath( 'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor) ) is_mamba_package = self.packer.is_mamba_package(path) self.assertTrue(is_mamba_package) self.packer.do( ['rm', 'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor)] ) @defer.inlineCallbacks def test_is_mamba_package_for_tar_file(self): result = yield utils.getProcessValue('mamba-admin', [], os.environ) if result == 1: raise unittest.SkipTest('mamba framework is not installed yet') with self._generate_docs(): self.config.parseOptions() self.config['name'] = 'mamba-dummy' self.packer.pack_application( 'sdist', self.config, config.Application('config/application.json') ) self.assertTrue(os.path.exists('mamba-dummy-0.1.2.tar.gz')) path = filepath.FilePath('mamba-dummy-0.1.2.tar.gz') is_mamba_package = self.packer.is_mamba_package(path) self.assertTrue(is_mamba_package) self.packer.do(['rm', 'mamba-dummy-0.1.2.tar.gz']) @contextmanager def _generate_README_and_LICENSE(self): with fake_project(): self.packer.do(['touch', 'README.rst']) self.packer.do(['touch', 'LICENSE']) yield self.packer.do(['rm', 'README.rst', 'LICENSE']) @contextmanager def _generate_docs(self): if skip_command_line_tests is True: raise unittest.SkipTest('skip_command_line_tests is set as True') with self._generate_README_and_LICENSE(): self.packer.do(['mkdir', 'docs']) yield self.packer.do(['rmdir', 'docs'])
class PackagePackerTest(unittest.TestCase): def setUp(self): self.packer = Packer() self.config = PackagePackOptions() def tearDown(self): with fake_project(): self.packer.do(['rm', 'README.rst']) self.packer.do(['rm', 'LICENSE']) self.packer.do(['rmdir', 'docs']) def test_do(self): self.packer.do(['touch', 'test_file.tmp']) self.assertTrue(os.path.exists('test_file.tmp')) self.packer.do(['rm', 'test_file.tmp']) self.assertFalse(os.path.exists('test_file.tmp')) def test_pack_fails_on_no_README_or_no_LICENSE(self): with fake_project(): self.config.parseOptions() self.assertRaises( usage.UsageError, self.packer.pack_application, 'sdist', self.config, config.Application('config/application.json') ) def test_pack_fails_on_no_docs_directory(self): with self._generate_README_and_LICENSE(): self.config.parseOptions() self.assertRaises( usage.UsageError, self.packer.pack_application, 'sdist', self.config, config.Application('config/application.json') ) self.assertTrue(os.path.exists('README.rst')) self.assertTrue(os.path.exists('LICENSE')) self.assertFalse(os.path.exists('docs')) @defer.inlineCallbacks def test_pack_sdist(self): result = yield utils.getProcessValue('mamba-admin', [], os.environ) if result == 1: raise unittest.SkipTest('mamba framework is not installed yet') with self._generate_docs(): self.config.parseOptions() self.config['name'] = 'mamba-dummy' self.packer.pack_application( 'sdist', self.config, config.Application('config/application.json') ) self.assertTrue(os.path.exists('mamba-dummy-0.1.2.tar.gz')) self.packer.do(['rm', 'mamba-dummy-0.1.2.tar.gz']) @defer.inlineCallbacks def test_pack_egg(self): result = yield utils.getProcessValue('mamba-admin', [], os.environ) if result == 1: raise unittest.SkipTest('mamba framework is not installed yet') with self._generate_docs(): self.config.parseOptions() self.config['name'] = 'mamba-dummy' self.packer.pack_application( 'bdist_egg', self.config, config.Application('config/application.json') ) major, minor = sys.version_info[:2] self.assertTrue(os.path.exists( 'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor)) ) self.packer.do( ['rm', 'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor)] ) def test_is_mamba_package_for_tar_file(self): pass @contextmanager def _generate_README_and_LICENSE(self): with fake_project(): self.packer.do(['touch', 'README.rst']) self.packer.do(['touch', 'LICENSE']) yield self.packer.do(['rm', 'README.rst', 'LICENSE']) @contextmanager def _generate_docs(self): if skip_command_line_tests is True: raise unittest.SkipTest('skip_command_line_tests is set as True') with self._generate_README_and_LICENSE(): self.packer.do(['mkdir', 'docs']) yield self.packer.do(['rmdir', 'docs'])
class PackagePackerTest(unittest.TestCase): def setUp(self): self.packer = Packer() self.config = PackagePackOptions() def tearDown(self): with fake_project(): self.packer.do(['rm', 'README.rst']) self.packer.do(['rm', 'LICENSE']) self.packer.do(['rmdir', 'docs']) def test_do(self): self.packer.do(['touch', 'test_file.tmp']) self.assertTrue(os.path.exists('test_file.tmp')) self.packer.do(['rm', 'test_file.tmp']) self.assertFalse(os.path.exists('test_file.tmp')) def test_pack_fails_on_no_README_or_no_LICENSE(self): with fake_project(): self.config.parseOptions() self.assertRaises( usage.UsageError, self.packer.pack_application, 'sdist', self.config, config.Application('config/application.json') ) def test_pack_fails_on_no_docs_directory(self): with self._generate_README_and_LICENSE(): self.config.parseOptions() self.assertRaises( usage.UsageError, self.packer.pack_application, 'sdist', self.config, config.Application('config/application.json') ) self.assertTrue(os.path.exists('README.rst')) self.assertTrue(os.path.exists('LICENSE')) self.assertFalse(os.path.exists('docs')) def test_pack_sdist(self): with self._generate_docs(): self.config.parseOptions() self.config['name'] = 'mamba-dummy' self.packer.pack_application( 'sdist', self.config, config.Application('config/application.json') ) self.assertTrue(os.path.exists('mamba-dummy-0.1.2.tar.gz')) self.packer.do(['rm', 'mamba-dummy-0.1.2.tar.gz']) def test_pack_egg(self): with self._generate_docs(): self.config.parseOptions() self.config['name'] = 'mamba-dummy' self.packer.pack_application( 'bdist_egg', self.config, config.Application('config/application.json') ) major, minor = sys.version_info[:2] self.assertTrue(os.path.exists( 'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor)) ) self.packer.do( ['rm', 'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor)] ) def test_is_mamba_package_for_tar_file(self): pass @contextmanager def _generate_README_and_LICENSE(self): with fake_project(): self.packer.do(['touch', 'README.rst']) self.packer.do(['touch', 'LICENSE']) yield self.packer.do(['rm', 'README.rst', 'LICENSE']) @contextmanager def _generate_docs(self): if skip_command_line_tests is True: raise unittest.SkipTest('skip_command_line_tests is set as True') with self._generate_README_and_LICENSE(): self.packer.do(['mkdir', 'docs']) yield self.packer.do(['rmdir', 'docs'])