@@ -1184,6 +1184,48 @@ async def test_create_with_object_template(
11841184 assert sorted ([(await sfp .interface .get_peer (db = db )).name .value for sfp in device_sfps ]) == if_names
11851185
11861186
1187+ async def test_create_without_object_template (
1188+ db : InfrahubDatabase , default_branch : Branch , register_core_models_schema : SchemaBranch
1189+ ):
1190+ registry .schema .register_schema (schema = DEVICE_SCHEMA , branch = default_branch .name )
1191+
1192+ query = """
1193+ mutation NewDevice($device_name: String!, $manufacturer: String!) {
1194+ TestingDeviceCreate(data: {
1195+ name: {value: $device_name}
1196+ manufacturer: {value: $manufacturer}
1197+ height: {value: 1}
1198+ weight: {value: 6}
1199+ airflow: {value: "Front to rear"}
1200+ }) {
1201+ ok
1202+ object {
1203+ id
1204+ }
1205+ }
1206+ }
1207+ """
1208+ gql_params = await prepare_graphql_params (db = db , include_subscription = False , branch = default_branch )
1209+
1210+ result = await graphql (
1211+ schema = gql_params .schema ,
1212+ source = query ,
1213+ context_value = gql_params .context ,
1214+ root_value = None ,
1215+ variable_values = {"device_name" : "th2.par.asbr01" , "manufacturer" : "Juniper" },
1216+ )
1217+ assert not result .errors
1218+
1219+ device = await NodeManager .get_one (
1220+ db = db , kind = "TestingDevice" , branch = default_branch , id = result .data ["TestingDeviceCreate" ]["object" ]["id" ]
1221+ )
1222+ assert device
1223+ assert device .name .value == "th2.par.asbr01"
1224+ # Validate object not is linked to object template
1225+ device_template_node = await device .object_template .get_peer (db = db )
1226+ assert not device_template_node
1227+
1228+
11871229# These tests have been moved at the end of the file to avoid colliding with other and breaking them
11881230
11891231
0 commit comments