def test_save_overwrite(self, schema, tmpdir): tmpfile = tmpdir.mkdir('test_save').join('.schema.json') tmpfile.write('content') save(schema, str(tmpfile), True) assert SortedDict(loads(tmpfile.read())) == schema
def test_save_overwrite(self, schema: SortedDict, tmpdir: LocalPath): tmpfile: LocalPath = tmpdir.mkdir("test_save").join(".schema.json") tmpfile.write("content") save(schema, str(tmpfile), True) assert SortedDict(loads(tmpfile.read())) == schema
def test_save_new(self, schema: SortedDict, overwrite: bool, tmpdir: LocalPath): tmpfile: LocalPath = tmpdir.mkdir("test_save").join(".schema.json") save(schema, str(tmpfile), overwrite) assert SortedDict(loads(tmpfile.read())) == schema
def init(context: Context): """Create a schema file in the given directory Args: context (Context): Runtime settings object. Raises: OSError: File operation error. Error type raised may be a subclass of OSError. """ from os.path import join from syphon.schema import save schema_path = join(context.archive, context.schema_file) save(context.schema, schema_path, context.overwrite) if context.verbose: print('Init: wrote {0}'.format(schema_path))
def test_save_fileexistserror(self, tmpdir): tmpfile = tmpdir.mkdir('test_save').join('.schema.json') tmpfile.write('content') with pytest.raises(FileExistsError): save(TestSave.single_schema, str(tmpfile), False)
def test_save_new(self, schema, overwrite, tmpdir): tmpfile = tmpdir.mkdir('test_save').join('.schema.json') save(schema, str(tmpfile), overwrite) assert SortedDict(loads(tmpfile.read())) == schema
def test_save_fileexistserror(self, tmpdir: LocalPath): tmpfile: LocalPath = tmpdir.mkdir("test_save").join(".schema.json") tmpfile.write("content") with pytest.raises(FileExistsError): save(TestSave.single_schema, str(tmpfile), False)