Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
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))
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
    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)