Beispiel #1
0
        def run_assertion(method, description, args, expected):
            description = method + ': ' + description
            print
            print "Running", description, method
            method = {
                'diff': diff,
                'apply_diff': apply_diff,
                'transform': transform_object_diff
            }[method]

            if method is transform_object_diff:
                if len(args) == 3:
                    original, obja, objb = args
                    policy = None
                else:
                    original, obja, objb, policy = args
                diffa = diff(original, obja, policy)['v']
                diffb = diff(original, objb, policy)['v']
                tdiff = transform_object_diff(diffa, diffb, original, policy)
                intermediate = apply_diff(original, diffb)
                method = apply_diff
                args = [intermediate, tdiff]

            got = method(*args)
            if not equals(got, expected):
                print
                print "Exception coming..."
                print
                print "\tdescription", description
                print "\tgot", simplejson.dumps(got)
                print "\texp", simplejson.dumps(expected)
            return equals(got, expected)
Beispiel #2
0
        def run_assertion(method, description, args, expected):
            description = method + ': ' + description
            print
            print "Running", description, method
            method = {
                'diff': diff,
                'apply_diff': apply_diff,
                'transform': transform_object_diff
            }[method]

            if method is transform_object_diff:
                if len(args) == 3:
                    original, obja, objb = args
                    policy = None
                else:
                    original, obja, objb, policy = args
                diffa = diff(original, obja, policy)['v']
                diffb = diff(original, objb, policy)['v']
                tdiff = transform_object_diff(diffa, diffb, original, policy)
                intermediate = apply_diff(original, diffb)
                method = apply_diff
                args = [intermediate, tdiff]

            got = method(*args)
            if not equals(got, expected):
                print
                print "Exception coming..."
                print
                print "\tdescription", description
                print "\tgot", simplejson.dumps(got)
                print "\texp", simplejson.dumps(expected)
            return equals(got, expected)
Beispiel #3
0
 def test_transform(self):
     """(andy) just trying to work out transforms. i don't think i've
     quite got it yet, fred just committing this to have something to chat
     through with you.
     """
     # odiff = {"a": {"o": "r", "v": 7}}
     odiff = {"e": {"o": "+", "v": "y"}}
     o = {"a": "b"}
     diff = {"e": {"o": "+", "v": "d"}}
     print "FROAR", transform_object_diff(diff, odiff, o)
Beispiel #4
0
 def test_transform(self):
     """(andy) just trying to work out transforms. i don't think i've
     quite got it yet, fred just committing this to have something to chat
     through with you.
     """
     # odiff = {"a": {"o": "r", "v": 7}}
     odiff = {"e": {"o": "+", "v": "y"}}
     o = {"a":"b"}
     diff = {"e": {"o": "+", "v": "d"}}
     print "FROAR", transform_object_diff(diff, odiff, o)