11"""Tests for SchemaForge — GraphQL SDL parser and generator."""
2+
23from __future__ import annotations
34
45import pytest
@@ -217,18 +218,29 @@ def test_generate_simple(self):
217218 Table (
218219 name = "User" ,
219220 columns = [
220- Column (name = "id" , type = ColumnType .STRING ,
221- nullable = False , primary_key = True ),
222- Column (name = "name" , type = ColumnType .STRING ,
223- nullable = False ),
224- Column (name = "email" , type = ColumnType .STRING ,
225- nullable = False , unique = True ),
226- Column (name = "age" , type = ColumnType .INTEGER ,
227- nullable = True ),
228- Column (name = "role" , type = ColumnType .CUSTOM ,
229- nullable = False , custom_type = "Role" ),
230- Column (name = "createdAt" , type = ColumnType .DATETIME ,
231- nullable = False ),
221+ Column (
222+ name = "id" ,
223+ type = ColumnType .STRING ,
224+ nullable = False ,
225+ primary_key = True ,
226+ ),
227+ Column (name = "name" , type = ColumnType .STRING , nullable = False ),
228+ Column (
229+ name = "email" ,
230+ type = ColumnType .STRING ,
231+ nullable = False ,
232+ unique = True ,
233+ ),
234+ Column (name = "age" , type = ColumnType .INTEGER , nullable = True ),
235+ Column (
236+ name = "role" ,
237+ type = ColumnType .CUSTOM ,
238+ nullable = False ,
239+ custom_type = "Role" ,
240+ ),
241+ Column (
242+ name = "createdAt" , type = ColumnType .DATETIME , nullable = False
243+ ),
232244 ],
233245 )
234246 ],
@@ -258,12 +270,14 @@ def test_generate_with_list_types(self):
258270 Table (
259271 name = "Product" ,
260272 columns = [
261- Column (name = "id" , type = ColumnType .STRING ,
262- nullable = False , primary_key = True ),
263- Column (name = "tags" , type = ColumnType .STRING ,
264- nullable = True ),
265- Column (name = "price" , type = ColumnType .FLOAT ,
266- nullable = True ),
273+ Column (
274+ name = "id" ,
275+ type = ColumnType .STRING ,
276+ nullable = False ,
277+ primary_key = True ,
278+ ),
279+ Column (name = "tags" , type = ColumnType .STRING , nullable = True ),
280+ Column (name = "price" , type = ColumnType .FLOAT , nullable = True ),
267281 ],
268282 )
269283 ],
@@ -284,10 +298,18 @@ def test_generate_enum(self):
284298 Table (
285299 name = "Item" ,
286300 columns = [
287- Column (name = "id" , type = ColumnType .STRING ,
288- nullable = False , primary_key = True ),
289- Column (name = "status" , type = ColumnType .CUSTOM ,
290- nullable = False , custom_type = "Status" ),
301+ Column (
302+ name = "id" ,
303+ type = ColumnType .STRING ,
304+ nullable = False ,
305+ primary_key = True ,
306+ ),
307+ Column (
308+ name = "status" ,
309+ type = ColumnType .CUSTOM ,
310+ nullable = False ,
311+ custom_type = "Status" ,
312+ ),
291313 ],
292314 )
293315 ],
@@ -347,10 +369,18 @@ def test_enum_values_roundtrip(self):
347369 Table (
348370 name = "Item" ,
349371 columns = [
350- Column (name = "id" , type = ColumnType .STRING ,
351- nullable = False , primary_key = True ),
352- Column (name = "status" , type = ColumnType .CUSTOM ,
353- nullable = False , custom_type = "Status" ),
372+ Column (
373+ name = "id" ,
374+ type = ColumnType .STRING ,
375+ nullable = False ,
376+ primary_key = True ,
377+ ),
378+ Column (
379+ name = "status" ,
380+ type = ColumnType .CUSTOM ,
381+ nullable = False ,
382+ custom_type = "Status" ,
383+ ),
354384 ],
355385 )
356386 ],
@@ -378,9 +408,7 @@ def test_enum_values_roundtrip(self):
378408
379409class TestGraphQLCrossFormat :
380410 def test_graphql_to_sql (self ):
381- result = convert_schema (
382- GRAPHQL_SIMPLE_ROUNDTRIP , "graphql" , "sql"
383- )
411+ result = convert_schema (GRAPHQL_SIMPLE_ROUNDTRIP , "graphql" , "sql" )
384412 assert "CREATE TABLE" in result
385413 assert "Item" in result
386414 assert "id" in result and "name" in result and "price" in result
@@ -450,9 +478,7 @@ def test_prisma_to_graphql(self):
450478
451479
452480def test_graphql_fixture_file ():
453- fixture_path = (
454- Path (__file__ ).parent .parent / "fixtures" / "sample.graphql"
455- )
481+ fixture_path = Path (__file__ ).parent .parent / "fixtures" / "sample.graphql"
456482 if not fixture_path .exists ():
457483 pytest .skip ("Fixture file not found" )
458484 text = fixture_path .read_text (encoding = "utf-8" )
0 commit comments