コード例 #1
0
ファイル: test_operations.py プロジェクト: ghickman/json-spec
    def test_remove(self):
        obj = {'foo': 'bar'}
        response = remove(obj, '/foo')
        assert response == {}
        assert response != obj

        with self.assertRaises(Error):
            assert remove({'foo': 'bar'}, '/bar')
コード例 #2
0
ファイル: test_operations.py プロジェクト: xlevus/json-spec
    def test_remove(self):
        obj = {'foo': 'bar'}
        response = remove(obj, '/foo')
        assert response == {}
        assert response != obj

        with self.assertRaises(Error):
            assert remove({'foo': 'bar'}, '/bar')
コード例 #3
0
def test_remove():
    obj = {'foo': 'bar'}
    response = remove(obj, '/foo')
    assert response == {}
    assert response != obj

    with pytest.raises(Error):
        assert remove({'foo': 'bar'}, '/bar')
コード例 #4
0
def test_remove():
    obj = {'foo': 'bar'}
    response = remove(obj, '/foo')
    assert response == {}
    assert response != obj

    with pytest.raises(Error):
        assert remove({'foo': 'bar'}, '/bar')
コード例 #5
0
ファイル: test_operations.py プロジェクト: ghickman/json-spec
 def test_remove_array_element(self):
     obj = {
         'foo': ['bar', 'qux', 'baz']
     }
     assert remove(obj, '/foo/1') == {
         'foo': ['bar', 'baz']
     }
コード例 #6
0
    def run(self, args):
        parse_pointer(args)
        parse_document(args)

        from jsonspec.operations import remove, Error
        from jsonspec.pointer import ParseError

        try:
            response = remove(args.document, args.pointer)
            return driver.dumps(response, indent=args.indent)
        except Error:
            raise Exception('{} does not match'.format(args.pointer))
        except ParseError:
            raise Exception('{} is not a valid pointer'.format(args.pointer))
コード例 #7
0
ファイル: cli.py プロジェクト: johnnoone/json-spec
    def run(self, args):
        parse_pointer(args)
        parse_document(args)

        from jsonspec.operations import remove, Error
        from jsonspec.pointer import ParseError

        try:
            response = remove(args.document, args.pointer)
            return driver.dumps(response, indent=args.indent)
        except Error:
            raise Exception('{} does not match'.format(args.pointer))
        except ParseError:
            raise Exception('{} is not a valid pointer'.format(args.pointer))
コード例 #8
0
ファイル: test_operations.py プロジェクト: ghickman/json-spec
 def test_remove_object_member(self):
     obj = {
         'baz': 'qux',
         'foo': 'bar'
     }
     assert remove(obj, '/baz') == {'foo': 'bar'}
コード例 #9
0
ファイル: test_operations.py プロジェクト: xlevus/json-spec
 def test_remove_array_element(self):
     obj = {'foo': ['bar', 'qux', 'baz']}
     assert remove(obj, '/foo/1') == {'foo': ['bar', 'baz']}
コード例 #10
0
ファイル: test_operations.py プロジェクト: xlevus/json-spec
 def test_remove_object_member(self):
     obj = {'baz': 'qux', 'foo': 'bar'}
     assert remove(obj, '/baz') == {'foo': 'bar'}