Exemplo n.º 1
0
    def testCase001(self):
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        jsonpatchlist += JSONPatchItem("replace", "/baz", "boo")
        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'replace', u'path': u'/baz', u'value': u'boo'}]"""
        assert ref == repr(jsonpatchlist)
Exemplo n.º 2
0
    def testCase001(self):
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        jsonpatchlist += JSONPatchItem("remove", "/foo/1")
        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'remove', u'path': u'/foo/1'}]"""
        assert ref == repr(jsonpatchlist)
Exemplo n.º 3
0
    def testCase001(self):
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        jsonpatchlist += JSONPatchItem("add", "/foo/1", "qux")
        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'add', u'path': u'/foo/1', u'value': u'qux'}]"""
        assert ref == repr(jsonpatchlist)
Exemplo n.º 4
0
    def testCase001(self):
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        patchfile = os.path.dirname(__file__) + os.sep + 'patch.jsonp'
        jsonpatchlist.patch_import(patchfile)

        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'remove', u'path': u'/foo/1'}]"""
        assert ref == repr(jsonpatchlist)
Exemplo n.º 5
0
    def testCase001(self):
        """Assemble patch list, Invalid JSON Patch Document
        """
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        patchfile = os.path.dirname(__file__) + os.sep + 'patch.jsonp'

        try:
            jsonpatchlist.patch_import(patchfile)
        except JSONPatchItemException as e:
            pass
Exemplo n.º 6
0
    def testCase001(self):
        """Assemble patch list, Adding to a Nonexistent Target
        """
        global configdata
        global appname
        global jsonpatchlist

        #
        # assemble patches
        jsonpatchlist  = JSONPatch()
        jsonpatchlist += JSONPatchItemRaw("""{ "op": "add", "path": "/baz/bat", "value": "qux" }""")
        ref=repr(jsonpatchlist)
        ref = """[{u'op': u'add', u'path': u'/baz/bat', u'value': u'qux'}]"""
        assert ref == repr(jsonpatchlist) # the complete patch list
Exemplo n.º 7
0
    def testCase001(self):
        """Assemble patch list
        """
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        patchfile = os.path.dirname(__file__) + os.sep + 'patch.jsonp'
        jsonpatchlist.patch_import(patchfile)

        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'add', u'path': u'/child', u'value': {u'grandchild': {}}}]"""
        assert ref == repr(jsonpatchlist)  # the complete patch list
Exemplo n.º 8
0
    def testCase001(self):
        """Assemble patch list, Comparing Strings and Numbers
        """
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        patchfile = os.path.dirname(__file__) + os.sep + 'patch.jsonp'
        jsonpatchlist.patch_import(patchfile)

        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'test', u'path': u'/~1', u'value': u'10'}]"""
        assert ref == repr(jsonpatchlist)  # the complete patch list
Exemplo n.º 9
0
    def testCase001(self):
        """Assemble patch list, Adding an Array Value
        """
        global configdata
        global appname
        global jsonpatchlist

        #
        # assemble patches
        jsonpatchlist  = JSONPatch()
        jsonpatchlist += JSONPatchItemRaw("""{ "op": "add", "path": "/foo/-", "value": ["abc", "def"] }""")
        ref=repr(jsonpatchlist)
        ref = """[{u'op': u'add', u'path': u'/foo/-', u'value': [u'abc', u'def']}]"""
        assert ref == repr(jsonpatchlist) # the complete patch list
Exemplo n.º 10
0
    def testCase001(self):
        """Assemble patch list
        """
        global configdata
        global appname
        global jsonpatchlist

        #
        # assemble patches
        jsonpatchlist  = JSONPatch()
        jsonpatchlist += JSONPatchItem("test", "/baz", "bar")
        ref=repr(jsonpatchlist)
        ref = """[{u'op': u'test', u'path': u'/baz', u'value': u'bar'}]"""
        assert ref == repr(jsonpatchlist) # the complete patch list
Exemplo n.º 11
0
    def testCase001(self):
        """Assemble patch list, Adding to a Nonexistent Target
        """
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        patchfile = os.path.dirname(__file__) + os.sep + 'patch.jsonp'
        jsonpatchlist.patch_import(patchfile)

        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'add', u'path': u'/baz/bat', u'value': u'qux'}]"""
        assert ref == repr(jsonpatchlist)  # the complete patch list
Exemplo n.º 12
0
    def testCase001(self):
        """Create an object for patch only - no schema.
        """
        global patchdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        patchfile = os.path.dirname(__file__) + os.sep + 'patch.jsonp'
        jsonpatchlist.patch_import(patchfile)

        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'add', u'path': u'/baz', u'value': u'qux'}]"""
        assert ref == repr(jsonpatchlist)
Exemplo n.º 13
0
    def testCase001(self):
        """Assemble patch list, Adding an Array Value
        """
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        patchfile = os.path.dirname(__file__) + os.sep + 'patch.jsonp'
        jsonpatchlist.patch_import(patchfile)

        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'add', u'path': u'/foo/-', u'value': [u'abc', u'def']}]"""
        assert ref == repr(jsonpatchlist)  # the complete patch list
Exemplo n.º 14
0
    def testCase001(self):
        """Assemble patch list, Ignoring Unrecognized Elements
        """
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        patchfile = os.path.dirname(__file__) + os.sep + 'patch.jsonp'
        jsonpatchlist.patch_import(patchfile)

        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'add', u'path': u'/baz', u'value': u'qux'}]"""
        assert ref == repr(jsonpatchlist)  # the complete patch list
Exemplo n.º 15
0
    def testCase001(self):
        """Assemble patch list
        """
        global configdata
        global appname
        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        patchfile = os.path.dirname(__file__)+os.sep+'patch.jsonp'
        jsonpatchlist.patch_import(patchfile)

        ref=repr(jsonpatchlist)
        ref = """[{u'op': u'test', u'path': u'/baz', u'value': u'qux'}, {u'op': u'test', u'path': u'/foo/1', u'value': 2}]"""
        assert ref == repr(jsonpatchlist) # the complete patch list
Exemplo n.º 16
0
    def testCase001(self):
        """Assemble patch list, Ignoring Unrecognized Elements
        """
        global configdata
        global appname
        global jsonpatchlist

        #
        # assemble patches
        jsonpatchlist = JSONPatch()
        jsonpatchlist += JSONPatchItemRaw(
            """{ "op": "add", "path": "/baz", "value": "qux", "xyz": 123 }""")
        ref = repr(jsonpatchlist)
        ref = """[{u'op': u'add', u'path': u'/baz', u'value': u'qux'}]"""
        assert ref == repr(jsonpatchlist)  # the complete patch list
Exemplo n.º 17
0
    def testCase001(self):
        """Assemble patch list
        """
        global configdata
        global appname
        global jsonpatchlist

        #
        # assemble patches
        jsonpatchlist  = JSONPatch()
        jsonpatchlist += JSONPatchItem("replace", "/baz", "boo")
        jsonpatchlist += JSONPatchItem("test", "/foo/1", 2)
        ref=repr(jsonpatchlist)
        ref = """[{u'op': u'replace', u'path': u'/baz', u'value': u'boo'}, {u'op': u'test', u'path': u'/foo/1', u'value': 2}]"""
        assert ref == repr(jsonpatchlist) # the complete patch list
Exemplo n.º 18
0
    def testCase003(self):
        """Create a patch task list.
        """
        global configdata
        global appname

        global jsonpatchlist

        jsonpatchlist = JSONPatch()
        for i in range(0, 10):
            jsonpatchlist += JSONPatchItem("add", "/a" + unicode(i),
                                           "v" + unicode(i))

        #ref = repr(jsonpatchlist)
        #print ref
        ref = """[{u'op': u'add', u'path': u'/a0', u'value': u'v0'}, {u'op': u'add', u'path': u'/a1', u'value': u'v1'}, {u'op': u'add', u'path': u'/a2', u'value': u'v2'}, {u'op': u'add', u'path': u'/a3', u'value': u'v3'}, {u'op': u'add', u'path': u'/a4', u'value': u'v4'}, {u'op': u'add', u'path': u'/a5', u'value': u'v5'}, {u'op': u'add', u'path': u'/a6', u'value': u'v6'}, {u'op': u'add', u'path': u'/a7', u'value': u'v7'}, {u'op': u'add', u'path': u'/a8', u'value': u'v8'}, {u'op': u'add', u'path': u'/a9', u'value': u'v9'}]"""
        assert ref == repr(jsonpatchlist)
Exemplo n.º 19
0
    def testCase003(self):
        """Assemble patch list, Invalid JSON Patch Document
        """
        global configdata
        global appname
        global jsonpatchlist

        #
        # assemble patches
        jsonpatchlist = JSONPatch()

        try:
            jsonpatchlist += JSONPatchItemRaw(
                """{ "op": "add", "path": "/baz", "value": "qux", "path": "/baz" }"""
            )
        except JSONPatchItemException as e:
            pass
Exemplo n.º 20
0
    def testCase001(self):
        """Assemble patch list
        """
        global configdata
        global appname
        global jsonpatchlist

        #
        # assemble patches
        jsonpatchlist = JSONPatch()
        jsonpatchlist += JSONPatchItem("add", "/child", {"grandchild": {}})

        ref = [{
            u'op': u'add',
            u'path': u'/child',
            u'value': {
                'grandchild': {}
            }
        }]
        assert ref == jsonpatchlist
        assert jsonpatchlist == ref
        pass