Fix test for same dicts

This commit is contained in:
Antonio J. Delgado 2024-11-11 09:20:18 +02:00
parent f621440116
commit bd769f9e3f

View file

@ -615,13 +615,22 @@ class NextcloudHandler:
else: else:
self.exit.status_code_error(r.status_code) self.exit.status_code_error(r.status_code)
def is_same_key(self, key, dict1, dict2):
'''Test if two dictionaries have the same key with the same value'''
if key in dict1 and key in dict2:
if dict1[key] == dict2[key]:
return True
return False
def is_same_password(self, obj1, obj2): def is_same_password(self, obj1, obj2):
'''Test if two password objects are the same or similar''' '''Test if two password objects are the same or similar'''
if obj1 == obj2: if obj1 == obj2:
return True return True
if (obj1['username'] == obj2['username'] and if (
obj1['password'] == obj2['password'] and self.is_same_key('username', obj1, obj2) and
obj1['url'] == obj2['url']): self.is_same_key('password', obj1, obj2) and
self.is_same_key('url', obj1, obj2)
):
return True return True
return False return False