def test_create_project_files_with_ui(self): # Test the creation of zapp.yaml and ui template files tempdir = tempfile.mkdtemp() expected_files = [ os.path.join(tempdir, x) for x in ('zapp.yaml', 'index.html.tmpl', 'style.css', 'zerocloud.js') ] filepath = os.path.join(tempdir, 'zapp.yaml') name = os.path.basename(tempdir) try: assert not os.path.exists(filepath) created_files = zpm._create_project_files(tempdir, with_ui=True) for each in created_files: assert os.path.exists(each) # test the zapp.yaml contents zapp_yaml = created_files[0] with open(zapp_yaml) as fp: expected = yaml.load(zpm.render_zapp_yaml( name, template_name='zapp-with-ui.yaml' )) assert expected == yaml.load(fp) assert os.path.abspath(filepath) == os.path.abspath(zapp_yaml) assert expected_files == created_files finally: shutil.rmtree(tempdir)
def test_create_zapp_yaml(self): # Test the creation of zapp.yaml. tempdir = tempfile.mkdtemp() filepath = os.path.join(tempdir, 'zapp.yaml') name = os.path.basename(tempdir) try: assert not os.path.exists(filepath) zapp_yaml = zpm._create_zapp_yaml(tempdir) assert os.path.exists(filepath) with open(filepath) as fp: expected = yaml.load(zpm.render_zapp_yaml(name)) assert expected == yaml.load(fp) assert os.path.abspath(filepath) == os.path.abspath(zapp_yaml) finally: shutil.rmtree(tempdir)
def test_key_ordering(self, yaml_map): # This makes yaml.safe_load use an OrderedDict instead of a # normal dict when loading a YAML mapping. yaml_map.__iter__.return_value = iter(OrderedDict()) # Test the creation of zapp.yaml. tempdir = tempfile.mkdtemp() filepath = os.path.join(tempdir, 'zapp.yaml') try: zpm._create_zapp_yaml(tempdir) with open(filepath) as fp: loaded = yaml.safe_load(fp) tmpl = yaml.safe_load(zpm.render_zapp_yaml('')) assert loaded.keys() == tmpl.keys() finally: shutil.rmtree(tempdir)