Skip to content

Commit

Permalink
Add new test for get_objects in object_type
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjcardona13 committed Jun 27, 2024
1 parent cffa5cc commit f3999f2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"workbench.colorTheme": "Default Dark+"
"workbench.colorTheme": "PyCharm Dark+ Theme"
}
6 changes: 6 additions & 0 deletions tests/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class ExtraFieldsModelG:
class ObjectType:
extra_field_object_type = graphene.String()

@classmethod
def get_objects(cls_object_type, objects, info, **kwargs):
new_obj_g = ModelG(name="MODEL G FROM GET OBJECTS")
new_obj_g.save()
return ModelG.objects.filter(name="MODEL G FROM GET OBJECTS")

class InputObjectType:
extra_field_input_object_type = graphene.String()

Expand Down
38 changes: 38 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,44 @@ def test_search_operation_fiel(self):
# endregion


class TestInternalGetObjectsModelG(SchemaTestCase):
def test_get_objects_model_g(self):
client = Client()

variables = {"input": [{"name": "MODEL G NAME"}]}
expected_response = {
"data": {
"createModelGs": {
"objects": [
{
"id": "1",
"name": "MODEL G NAME",
"paginatedForeignKeyHRelated": {"objects": []},
},
],
"errorsReport": None,
}
}
}
response = client.query(create_model_g_mutation, variables=variables).json()
self.verify_response(response, expected_response, message="CREATE ModelG")

# region READ ModelC
variables = {"where": {"id": {"exact": "1"}}}
expected_response = {
"data": {
"readModelG": {
"id": "2",
"name": "MODEL G FROM GET OBJECTS",
"paginatedForeignKeyHRelated": {"objects": []},
}
}
}
response = client.query(read_model_g_query, variables=variables).json()
self.verify_response(response, expected_response, message="READ ModelG")
# endregion


class CruddalsModelSchemaTestResolvers(SchemaTestCase):
def test_cruddals_model_c(self):
client = Client()
Expand Down

0 comments on commit f3999f2

Please sign in to comment.