def test_file_already_exists(self): tempdir = tempfile.mkdtemp() filepath = os.path.join(tempdir, 'zapp.yaml') # "touch" the file open(filepath, 'w').close() try: with pytest.raises(RuntimeError): zpm._create_zapp_yaml(tempdir) 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)
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)