예제 #1
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
예제 #2
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
예제 #3
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
예제 #4
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