From c5ac66236abed6e5e3afa3d51c9a73b2e3235b48 Mon Sep 17 00:00:00 2001 From: Andre Senna <“andre.senna@gmail.com”> Date: Tue, 26 Mar 2024 11:59:28 -0300 Subject: [PATCH 1/2] Enhance equality check between dicts Compare only common fields instead of using `==` whioch compares the whole dict. --- tests/integration/test_remote_das.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/integration/test_remote_das.py b/tests/integration/test_remote_das.py index beca4a9f..2684adff 100644 --- a/tests/integration/test_remote_das.py +++ b/tests/integration/test_remote_das.py @@ -10,6 +10,12 @@ from .helpers import metta_animal_base_handles from .remote_das_info import remote_das_host, remote_das_port +def _check_docs(actual, expected): + assert len(actual) == len(expected) + for dict1, dict2 in zip(actual, expected): + for key in dict2.keys(): + assert dict1[key] == dict2[key] + return True class TestRemoteDistributedAtomSpace: """Integration tests with OpenFaas function on the Vultr server. Using the Animal Knowledge Base""" @@ -168,7 +174,7 @@ def test_query(self, remote_das: DistributedAtomSpace): for _, link in answer: assert link['handle'] in all_inheritance_mammal if link['handle'] == metta_animal_base_handles.inheritance_chimp_mammal: - assert link['targets'] == [ + assert _check_docs(link['targets'], [ { 'handle': metta_animal_base_handles.Inheritance, 'type': 'Symbol', @@ -184,9 +190,9 @@ def test_query(self, remote_das: DistributedAtomSpace): 'type': 'Symbol', 'name': '"mammal"', }, - ] + ]) elif link['handle'] == metta_animal_base_handles.inheritance_human_mammal: - assert link['targets'] == [ + assert _check_docs(link['targets'], [ { 'handle': metta_animal_base_handles.Inheritance, 'type': 'Symbol', @@ -202,9 +208,9 @@ def test_query(self, remote_das: DistributedAtomSpace): 'type': 'Symbol', 'name': '"mammal"', }, - ] + ]) elif link['handle'] == metta_animal_base_handles.inheritance_monkey_mammal: - assert link['targets'] == [ + assert _check_docs(link['targets'], [ { 'handle': metta_animal_base_handles.Inheritance, 'type': 'Symbol', @@ -220,9 +226,9 @@ def test_query(self, remote_das: DistributedAtomSpace): 'type': 'Symbol', 'name': '"mammal"', }, - ] + ]) elif link['handle'] == metta_animal_base_handles.inheritance_rhino_mammal: - assert link['targets'] == [ + assert _check_docs(link['targets'], [ { 'handle': metta_animal_base_handles.Inheritance, 'type': 'Symbol', @@ -238,7 +244,7 @@ def test_query(self, remote_das: DistributedAtomSpace): 'type': 'Symbol', 'name': '"mammal"', }, - ] + ]) def test_get_traversal_cursor(self, remote_das: DistributedAtomSpace): cursor = remote_das.get_traversal_cursor(metta_animal_base_handles.human) From 15780ec3bea6da019106d9bd186319a321820919 Mon Sep 17 00:00:00 2001 From: Andre Senna <“andre.senna@gmail.com”> Date: Tue, 26 Mar 2024 12:01:31 -0300 Subject: [PATCH 2/2] Fix tests to compare dicts using only commom keys --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 9bcf3af9..28d440a6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,3 +5,4 @@ [#190] Implement custom_query() method in DAS API [#184] Fix bug that prevented DAS from answering nested queries properly [#202] Fix tests after adding complex typedef expressions +[BUGFIX] Fix tests to compare dicts using only commom keys