Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOTFIX] Fix tests to compare dicts using only commom keys #205

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 14 additions & 8 deletions tests/integration/test_remote_das.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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)
Expand Down
Loading