@@ -37,16 +37,30 @@ def compare(a, b): # type: (Any, Any) -> bool
37
37
# ignore empty collections
38
38
b = {k : v for k , v in b .iteritems ()
39
39
if not isinstance (v , (list , dict )) or len (v ) > 0 }
40
+ elif a .get ("class" ) == "Directory" :
41
+ if len (a ["listing" ]) != len (b ["listing" ]):
42
+ return False
43
+ for i in a ["listing" ]:
44
+ found = False
45
+ for j in b ["listing" ]:
46
+ try :
47
+ if compare (i , j ):
48
+ found = True
49
+ break
50
+ except :
51
+ pass
52
+ if not found :
53
+ raise CompareFail (u"%s not in %s" % (json .dumps (i , indent = 4 , sort_keys = True ), json .dumps (b , indent = 4 , sort_keys = True )))
40
54
41
55
a = {k : v for k , v in a .iteritems ()
42
- if k not in ("path" , "location" )}
56
+ if k not in ("path" , "location" , "listing" )}
43
57
b = {k : v for k , v in b .iteritems ()
44
- if k not in ("path" , "location" )}
58
+ if k not in ("path" , "location" , "listing" )}
45
59
46
60
if len (a ) != len (b ):
47
61
raise CompareFail (u"expected %s\n got %s" % (json .dumps (a , indent = 4 , sort_keys = True ), json .dumps (b , indent = 4 , sort_keys = True )))
48
62
for c in a :
49
- if a .get ("class" ) != "File" or c not in ("path" , "location" ):
63
+ if a .get ("class" ) != "File" or c not in ("path" , "location" , "listing" ):
50
64
if c not in b :
51
65
raise CompareFail (u"%s not in %s" % (c , b ))
52
66
if not compare (a [c ], b [c ]):
0 commit comments