def test_deployment(self): basepath = os.path.join(os.path.expanduser('~/')) d = Deployment('testapp', base=basepath) d.prepare_app() # check that sync_app worked self.assertTrue(os.path.exists(d.build_path)) # check that virtualenv was built ve_path = os.path.join(d.build_path, d.virtual) self.assertTrue(os.path.exists(ve_path)) # check we can add a file test_file = os.path.join(os.path.dirname(__file__), "data", "tip.tar.gz") d.add_to_root_fs(test_file, 'tip.tar.gz') dest_file = os.path.join(d.root_path, "tip.tar.gz") self.assertTrue(os.path.exists(dest_file)) # now check with a leading slash d.add_to_root_fs(test_file, '/tip.tar.gz') dest_file = os.path.join(d.root_path, "tip.tar.gz") self.assertTrue(os.path.exists(dest_file)) # check we can add data data = "this is some test data" d.add_data_to_root_fs(data, "test_data.txt") dest_file = os.path.join(d.root_path, "test_data.txt") self.assertTrue(os.path.exists(dest_file)) with open(dest_file) as f: self.assertEquals(data, f.read()) # try the same with a leading slash data = "this is some test data" d.add_data_to_root_fs(data, "/test_data.txt") dest_file = os.path.join(d.root_path, "test_data.txt") self.assertTrue(os.path.exists(dest_file)) with open(dest_file) as f: self.assertEquals(data, f.read()) # check we can compile python files d.compile_python() dest_file = os.path.join(d.build_path, 'data', 'hello.pyc') self.assertTrue(os.path.exists(dest_file)) # check we can clear .py and just leave .pyc files d.clear_py_files() dest_file = os.path.join(d.build_path, 'data', 'hello.py') self.assertFalse(os.path.exists(dest_file))
def test_deployment(self): basepath = os.path.join(os.path.expanduser('~/')) d = Deployment('testapp', base=basepath) d.prepare_app() # check that sync_app worked self.assertTrue(os.path.exists(d.build_path)) # check that virtualenv was built ve_path = os.path.join(d.build_path, d.virtual) self.assertTrue(os.path.exists(ve_path)) # check we can add a file test_file = os.path.join(os.path.dirname(__file__),"data", "tip.tar.gz") d.add_to_root_fs(test_file, 'tip.tar.gz') dest_file = os.path.join(d.root_path, "tip.tar.gz") self.assertTrue(os.path.exists(dest_file)) # now check with a leading slash d.add_to_root_fs(test_file, '/tip.tar.gz') dest_file = os.path.join(d.root_path, "tip.tar.gz") self.assertTrue(os.path.exists(dest_file)) # check we can add data data = "this is some test data" d.add_data_to_root_fs(data, "test_data.txt") dest_file = os.path.join(d.root_path, "test_data.txt") self.assertTrue(os.path.exists(dest_file)) with open(dest_file) as f: self.assertEquals(data, f.read()) # try the same with a leading slash data = "this is some test data" d.add_data_to_root_fs(data, "/test_data.txt") dest_file = os.path.join(d.root_path, "test_data.txt") self.assertTrue(os.path.exists(dest_file)) with open(dest_file) as f: self.assertEquals(data, f.read()) # check we can compile python files d.compile_python() dest_file = os.path.join(d.build_path, 'data', 'hello.pyc') self.assertTrue(os.path.exists(dest_file)) # check we can clear .py and just leave .pyc files d.clear_py_files() dest_file = os.path.join(d.build_path, 'data', 'hello.py') self.assertFalse(os.path.exists(dest_file))