Skip to content

Commit

Permalink
bit of a strange bug with inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
duboyal committed Apr 2, 2024
1 parent 1e5ed22 commit f145b97
Showing 1 changed file with 5 additions and 32 deletions.
37 changes: 5 additions & 32 deletions tests/nodes/primary_nodes/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,46 +108,19 @@ def test_save_project_change_material(cript_api, simple_project_node, complex_pr
pytest nodes/primary_nodes/test_project.py::test_save_project_change_material
"""

# with cript.API(host="https://lb-stage.mycriptapp.org/") as api:
# with open("new_project.json") as json_handle:
# proj_json = json.load(json_handle)
# proj = cript_api.load_nodes_from_json(nodes_json=proj_json)
# Modify deep in the tree

print("------------\nstarting")

proj0 = copy.deepcopy(complex_project_node)
proj_json = proj0.get_expanded_json() # .get_json().json
cript_api.save(proj0)

print("---- finished save --- now load node")

proj = load_nodes_from_json(nodes_json=proj_json)

print("\n----proj.collection[0].inventory[0].material[0]\n")

print(proj.collection[0].inventory[0].material[0].get_json().json)

proj_loaded, proj_cache = cript.load_nodes_from_json(nodes_json=proj0.get_expanded_json(), _use_uuid_cache={})

# --- finished save --- now load node
# making sure this is a different object loaded , instead of comparing the same object
proj_loaded, proj_cache = cript.load_nodes_from_json(nodes_json=proj_json, _use_uuid_cache={})
material_to_modify = proj_loaded.collection[0].inventory[0].material[0]
print("\n\n proj_loaded.collection[0].inventory[0].material[0]\n")
print(proj_loaded.collection[0].inventory[0].material[0].get_json().json)

material_to_modify.name = "this is sure to be a new name"

# Delete a node
proj_loaded.material[0].property = []

cript_api.save(proj_loaded)

# now we need to reload the test in

proj_loaded2, proj_cache = cript.load_nodes_from_json(nodes_json=proj_loaded.get_expanded_json(), _use_uuid_cache={})
print("\n\n proj_loaded2.collection[0].inventory[0].material[0]\n")
print(proj_loaded2.collection[0].inventory[0].material[0].get_json().json)

print("asserting")
print("")
print(proj_loaded2.collection[0].inventory[0].material[0].name)
proj_loaded2, proj2_cache = cript.load_nodes_from_json(nodes_json=proj_loaded.get_expanded_json(), _use_uuid_cache={})
# asserting
assert proj_loaded2.collection[0].inventory[0].material[0].name == "this is sure to be a new name"

0 comments on commit f145b97

Please sign in to comment.