Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
userpj committed Nov 25, 2024
1 parent 85ee4db commit a8fc85b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/tests/test_manifest_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import os
import unittest
from appbuilder import Manifest, manifest, manifest_parameter
from appbuilder.core.manifest.manifest_decorator import _merge_dict, _update_list


@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "")
Expand Down Expand Up @@ -192,6 +193,23 @@ def func(param: str = "[]") -> int:
"param" not in parameters["required"]
), "'param' should not be required as it has a default value"

def test_merge_dict(self):
self.assertEqual(_merge_dict({}, {}), {})
self.assertEqual(_merge_dict({}, {"a": 1}), {"a": 1})

def test_update_list(self):
def condition(item, new_item):
return item['id'] == new_item['id']

def replacer(item, new_item):
item.update(new_item)
return item

existing_item = {'id': 1, 'value': 'a'}
new_item = {'id': 1, 'value': 'b'}
list = [existing_item]
expected_result = [new_item]
self.assertEqual(_update_list(new_item, list, condition, replacer), expected_result)

if __name__ == "__main__":
unittest.main()

0 comments on commit a8fc85b

Please sign in to comment.