From 0738785d72f1927a631352a0db840235ffe71e8e Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 24 Feb 2024 14:01:19 +0100 Subject: [PATCH] test: Improve dump-schema snapshot test formatting Splitting the output into separate files and adding top-level newlines makes this much better to read and understand when looking at diffs. Inspired by #1699 --- ...chema_cache_snapshot[dbMediaHandlers].yaml | 19 + ...chema_cache_snapshot[dbRelationships].yaml | 1 + ...ema_cache_snapshot[dbRepresentations].yaml | 1 + ...est_schema_cache_snapshot[dbRoutines].yaml | 474 +++++++++++++++ .../test_schema_cache_snapshot[dbTables].yaml | 105 ++++ ...t_schema_cache_snapshot[dbTimezones].yaml} | 573 ------------------ test/io/test_cli.py | 29 +- 7 files changed, 627 insertions(+), 575 deletions(-) create mode 100644 test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbMediaHandlers].yaml create mode 100644 test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRelationships].yaml create mode 100644 test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRepresentations].yaml create mode 100644 test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRoutines].yaml create mode 100644 test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbTables].yaml rename test/io/__snapshots__/test_cli/{test_schema_cache_snapshot.yaml => test_schema_cache_snapshot[dbTimezones].yaml} (63%) diff --git a/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbMediaHandlers].yaml b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbMediaHandlers].yaml new file mode 100644 index 000000000..7b6317188 --- /dev/null +++ b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbMediaHandlers].yaml @@ -0,0 +1,19 @@ +- - - tag: RelAnyElement + - tag: MTGeoJSON + - - tag: BuiltinOvAggGeoJson + - tag: MTGeoJSON + +- - - tag: RelAnyElement + - tag: MTApplicationJSON + - - tag: BuiltinOvAggJson + - tag: MTApplicationJSON + +- - - tag: RelAnyElement + - tag: MTTextCSV + - - tag: BuiltinOvAggCsv + - tag: MTTextCSV + +- - - tag: RelAnyElement + - tag: MTAny + - - tag: BuiltinOvAggJson + - tag: MTApplicationJSON diff --git a/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRelationships].yaml b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRelationships].yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRelationships].yaml @@ -0,0 +1 @@ +[] diff --git a/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRepresentations].yaml b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRepresentations].yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRepresentations].yaml @@ -0,0 +1 @@ +[] diff --git a/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRoutines].yaml b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRoutines].yaml new file mode 100644 index 000000000..cc12ccd73 --- /dev/null +++ b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbRoutines].yaml @@ -0,0 +1,474 @@ +- - qiName: reload_pgrst_config + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: reload_pgrst_config + pdParams: [] + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: change_max_rows_config + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: change_max_rows_config + pdParams: + - ppName: val + ppReq: true + ppType: integer + ppTypeMaxLength: integer + ppVar: false + - ppName: notify + ppReq: false + ppType: boolean + ppTypeMaxLength: boolean + ppVar: false + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: reset_invalid_role_claim_key + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: reset_invalid_role_claim_key + pdParams: [] + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: multiple_func_settings_test + qiSchema: public + - - pdDescription: null + pdFuncSettings: + - - work_mem + - '5000' + - - statement_timeout + - 10s + pdHasVariadic: false + pdName: multiple_func_settings_test + pdParams: [] + pdReturnType: + contents: + contents: + qiName: record + qiSchema: pg_catalog + tag: Scalar + tag: SetOf + pdSchema: public + pdVolatility: Volatile + +- - qiName: serializable_isolation_level + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: serializable_isolation_level + pdParams: [] + pdReturnType: + contents: + contents: + qiName: text + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: hello + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: hello + pdParams: [] + pdReturnType: + contents: + contents: + qiName: text + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: get_pgrst_version + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: get_pgrst_version + pdParams: [] + pdReturnType: + contents: + contents: + qiName: text + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: terminate_pgrst + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: terminate_pgrst + pdParams: [] + pdReturnType: + contents: + contents: + qiName: record + qiSchema: pg_catalog + tag: Scalar + tag: SetOf + pdSchema: public + pdVolatility: Volatile + +- - qiName: default_isolation_level + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: default_isolation_level + pdParams: [] + pdReturnType: + contents: + contents: + qiName: text + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: set_statement_timeout + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: set_statement_timeout + pdParams: + - ppName: role + ppReq: true + ppType: text + ppTypeMaxLength: text + ppVar: false + - ppName: milliseconds + ppReq: true + ppType: integer + ppTypeMaxLength: integer + ppVar: false + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: change_db_schema_and_full_reload + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: change_db_schema_and_full_reload + pdParams: + - ppName: schemas + ppReq: true + ppType: text + ppTypeMaxLength: text + ppVar: false + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: work_mem_test + qiSchema: public + - - pdDescription: null + pdFuncSettings: + - - work_mem + - '6000' + pdHasVariadic: false + pdName: work_mem_test + pdParams: [] + pdReturnType: + contents: + contents: + qiName: text + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: invalid_role_claim_key_reload + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: invalid_role_claim_key_reload + pdParams: [] + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: reset_max_rows_config + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: reset_max_rows_config + pdParams: [] + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: uses_prepared_statements + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: uses_prepared_statements + pdParams: [] + pdReturnType: + contents: + contents: + qiName: bool + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: migrate_function + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: migrate_function + pdParams: [] + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: create_function + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: create_function + pdParams: [] + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: change_role_statement_timeout + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: change_role_statement_timeout + pdParams: + - ppName: timeout + ppReq: true + ppType: text + ppTypeMaxLength: text + ppVar: false + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: repeatable_read_isolation_level + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: repeatable_read_isolation_level + pdParams: [] + pdReturnType: + contents: + contents: + qiName: text + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: drop_change_cats + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: drop_change_cats + pdParams: [] + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: one_sec_timeout + qiSchema: public + - - pdDescription: null + pdFuncSettings: + - - statement_timeout + - 1s + pdHasVariadic: false + pdName: one_sec_timeout + pdParams: [] + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: sleep + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: sleep + pdParams: + - ppName: seconds + ppReq: true + ppType: double precision + ppTypeMaxLength: double precision + ppVar: false + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: get_postgres_version + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: get_postgres_version + pdParams: [] + pdReturnType: + contents: + contents: + qiName: int4 + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: four_sec_timeout + qiSchema: public + - - pdDescription: null + pdFuncSettings: + - - statement_timeout + - 4s + pdHasVariadic: false + pdName: four_sec_timeout + pdParams: [] + pdReturnType: + contents: + contents: + qiName: void + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile + +- - qiName: get_guc_value + qiSchema: public + - - pdDescription: null + pdFuncSettings: [] + pdHasVariadic: false + pdName: get_guc_value + pdParams: + - ppName: name + ppReq: true + ppType: text + ppTypeMaxLength: text + ppVar: false + pdReturnType: + contents: + contents: + qiName: text + qiSchema: pg_catalog + tag: Scalar + tag: Single + pdSchema: public + pdVolatility: Volatile diff --git a/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbTables].yaml b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbTables].yaml new file mode 100644 index 000000000..14954aaff --- /dev/null +++ b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbTables].yaml @@ -0,0 +1,105 @@ +- - qiName: authors_only + qiSchema: public + - tableColumns: {} + tableDeletable: true + tableDescription: null + tableInsertable: true + tableIsView: false + tableName: authors_only + tablePKCols: [] + tableSchema: public + tableUpdatable: true + +- - qiName: cats + qiSchema: public + - tableColumns: + id: + colDefault: null + colDescription: null + colEnum: [] + colMaxLen: null + colName: id + colNominalType: uuid + colNullable: false + colType: uuid + name: + colDefault: null + colDescription: null + colEnum: [] + colMaxLen: null + colName: name + colNominalType: text + colNullable: true + colType: text + tableDeletable: true + tableDescription: null + tableInsertable: true + tableIsView: false + tableName: cats + tablePKCols: + - id + tableSchema: public + tableUpdatable: true + +- - qiName: projects + qiSchema: public + - tableColumns: {} + tableDeletable: true + tableDescription: null + tableInsertable: true + tableIsView: false + tableName: projects + tablePKCols: [] + tableSchema: public + tableUpdatable: true + +- - qiName: items_w_isolation_level + qiSchema: public + - tableColumns: + id: + colDefault: null + colDescription: null + colEnum: [] + colMaxLen: null + colName: id + colNominalType: integer + colNullable: true + colType: integer + isolation_level: + colDefault: null + colDescription: null + colEnum: [] + colMaxLen: null + colName: isolation_level + colNominalType: text + colNullable: true + colType: text + tableDeletable: true + tableDescription: null + tableInsertable: true + tableIsView: true + tableName: items_w_isolation_level + tablePKCols: [] + tableSchema: public + tableUpdatable: true + +- - qiName: items + qiSchema: public + - tableColumns: + id: + colDefault: null + colDescription: null + colEnum: [] + colMaxLen: null + colName: id + colNominalType: integer + colNullable: true + colType: integer + tableDeletable: true + tableDescription: null + tableInsertable: true + tableIsView: false + tableName: items + tablePKCols: [] + tableSchema: public + tableUpdatable: true diff --git a/test/io/__snapshots__/test_cli/test_schema_cache_snapshot.yaml b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbTimezones].yaml similarity index 63% rename from test/io/__snapshots__/test_cli/test_schema_cache_snapshot.yaml rename to test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbTimezones].yaml index 3d84ca90f..eaf1fd709 100644 --- a/test/io/__snapshots__/test_cli/test_schema_cache_snapshot.yaml +++ b/test/io/__snapshots__/test_cli/test_schema_cache_snapshot[dbTimezones].yaml @@ -1,576 +1,3 @@ -dbMediaHandlers: -- - - tag: RelAnyElement - - tag: MTGeoJSON - - - tag: BuiltinOvAggGeoJson - - tag: MTGeoJSON -- - - tag: RelAnyElement - - tag: MTApplicationJSON - - - tag: BuiltinOvAggJson - - tag: MTApplicationJSON -- - - tag: RelAnyElement - - tag: MTTextCSV - - - tag: BuiltinOvAggCsv - - tag: MTTextCSV -- - - tag: RelAnyElement - - tag: MTAny - - - tag: BuiltinOvAggJson - - tag: MTApplicationJSON -dbRelationships: [] -dbRepresentations: [] -dbRoutines: -- - qiName: reload_pgrst_config - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: reload_pgrst_config - pdParams: [] - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: change_max_rows_config - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: change_max_rows_config - pdParams: - - ppName: val - ppReq: true - ppType: integer - ppTypeMaxLength: integer - ppVar: false - - ppName: notify - ppReq: false - ppType: boolean - ppTypeMaxLength: boolean - ppVar: false - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: reset_invalid_role_claim_key - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: reset_invalid_role_claim_key - pdParams: [] - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: multiple_func_settings_test - qiSchema: public - - - pdDescription: null - pdFuncSettings: - - - work_mem - - '5000' - - - statement_timeout - - 10s - pdHasVariadic: false - pdName: multiple_func_settings_test - pdParams: [] - pdReturnType: - contents: - contents: - qiName: record - qiSchema: pg_catalog - tag: Scalar - tag: SetOf - pdSchema: public - pdVolatility: Volatile -- - qiName: serializable_isolation_level - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: serializable_isolation_level - pdParams: [] - pdReturnType: - contents: - contents: - qiName: text - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: hello - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: hello - pdParams: [] - pdReturnType: - contents: - contents: - qiName: text - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: get_pgrst_version - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: get_pgrst_version - pdParams: [] - pdReturnType: - contents: - contents: - qiName: text - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: terminate_pgrst - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: terminate_pgrst - pdParams: [] - pdReturnType: - contents: - contents: - qiName: record - qiSchema: pg_catalog - tag: Scalar - tag: SetOf - pdSchema: public - pdVolatility: Volatile -- - qiName: default_isolation_level - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: default_isolation_level - pdParams: [] - pdReturnType: - contents: - contents: - qiName: text - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: set_statement_timeout - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: set_statement_timeout - pdParams: - - ppName: role - ppReq: true - ppType: text - ppTypeMaxLength: text - ppVar: false - - ppName: milliseconds - ppReq: true - ppType: integer - ppTypeMaxLength: integer - ppVar: false - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: change_db_schema_and_full_reload - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: change_db_schema_and_full_reload - pdParams: - - ppName: schemas - ppReq: true - ppType: text - ppTypeMaxLength: text - ppVar: false - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: work_mem_test - qiSchema: public - - - pdDescription: null - pdFuncSettings: - - - work_mem - - '6000' - pdHasVariadic: false - pdName: work_mem_test - pdParams: [] - pdReturnType: - contents: - contents: - qiName: text - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: invalid_role_claim_key_reload - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: invalid_role_claim_key_reload - pdParams: [] - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: reset_max_rows_config - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: reset_max_rows_config - pdParams: [] - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: uses_prepared_statements - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: uses_prepared_statements - pdParams: [] - pdReturnType: - contents: - contents: - qiName: bool - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: migrate_function - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: migrate_function - pdParams: [] - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: create_function - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: create_function - pdParams: [] - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: change_role_statement_timeout - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: change_role_statement_timeout - pdParams: - - ppName: timeout - ppReq: true - ppType: text - ppTypeMaxLength: text - ppVar: false - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: repeatable_read_isolation_level - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: repeatable_read_isolation_level - pdParams: [] - pdReturnType: - contents: - contents: - qiName: text - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: drop_change_cats - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: drop_change_cats - pdParams: [] - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: one_sec_timeout - qiSchema: public - - - pdDescription: null - pdFuncSettings: - - - statement_timeout - - 1s - pdHasVariadic: false - pdName: one_sec_timeout - pdParams: [] - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: sleep - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: sleep - pdParams: - - ppName: seconds - ppReq: true - ppType: double precision - ppTypeMaxLength: double precision - ppVar: false - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: get_postgres_version - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: get_postgres_version - pdParams: [] - pdReturnType: - contents: - contents: - qiName: int4 - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: four_sec_timeout - qiSchema: public - - - pdDescription: null - pdFuncSettings: - - - statement_timeout - - 4s - pdHasVariadic: false - pdName: four_sec_timeout - pdParams: [] - pdReturnType: - contents: - contents: - qiName: void - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -- - qiName: get_guc_value - qiSchema: public - - - pdDescription: null - pdFuncSettings: [] - pdHasVariadic: false - pdName: get_guc_value - pdParams: - - ppName: name - ppReq: true - ppType: text - ppTypeMaxLength: text - ppVar: false - pdReturnType: - contents: - contents: - qiName: text - qiSchema: pg_catalog - tag: Scalar - tag: Single - pdSchema: public - pdVolatility: Volatile -dbTables: -- - qiName: authors_only - qiSchema: public - - tableColumns: {} - tableDeletable: true - tableDescription: null - tableInsertable: true - tableIsView: false - tableName: authors_only - tablePKCols: [] - tableSchema: public - tableUpdatable: true -- - qiName: cats - qiSchema: public - - tableColumns: - id: - colDefault: null - colDescription: null - colEnum: [] - colMaxLen: null - colName: id - colNominalType: uuid - colNullable: false - colType: uuid - name: - colDefault: null - colDescription: null - colEnum: [] - colMaxLen: null - colName: name - colNominalType: text - colNullable: true - colType: text - tableDeletable: true - tableDescription: null - tableInsertable: true - tableIsView: false - tableName: cats - tablePKCols: - - id - tableSchema: public - tableUpdatable: true -- - qiName: projects - qiSchema: public - - tableColumns: {} - tableDeletable: true - tableDescription: null - tableInsertable: true - tableIsView: false - tableName: projects - tablePKCols: [] - tableSchema: public - tableUpdatable: true -- - qiName: items_w_isolation_level - qiSchema: public - - tableColumns: - id: - colDefault: null - colDescription: null - colEnum: [] - colMaxLen: null - colName: id - colNominalType: integer - colNullable: true - colType: integer - isolation_level: - colDefault: null - colDescription: null - colEnum: [] - colMaxLen: null - colName: isolation_level - colNominalType: text - colNullable: true - colType: text - tableDeletable: true - tableDescription: null - tableInsertable: true - tableIsView: true - tableName: items_w_isolation_level - tablePKCols: [] - tableSchema: public - tableUpdatable: true -- - qiName: items - qiSchema: public - - tableColumns: - id: - colDefault: null - colDescription: null - colEnum: [] - colMaxLen: null - colName: id - colNominalType: integer - colNullable: true - colType: integer - tableDeletable: true - tableDescription: null - tableInsertable: true - tableIsView: false - tableName: items - tablePKCols: [] - tableSchema: public - tableUpdatable: true -dbTimezones: - Africa/Abidjan - Africa/Accra - Africa/Addis_Ababa diff --git a/test/io/test_cli.py b/test/io/test_cli.py index e9caac132..498f10ece 100644 --- a/test/io/test_cli.py +++ b/test/io/test_cli.py @@ -27,6 +27,15 @@ import yaml from config import * +class ExtraNewLinesDumper(yaml.SafeDumper): + "Dumper that inserts an extra newline after each top-level item." + + def write_line_break(self, data=None): + super().write_line_break(data) + if len(self.indents) == 1: + super().write_line_break() + + class YamlSnapshotExtension(SingleFileSnapshotExtension): _file_extension = "yaml" @@ -238,9 +247,25 @@ def test_invalid_openapi_mode(invalidopenapimodes, defaultenv): # If this test is failing, run pytest with --snapshot-update. -def test_schema_cache_snapshot(baseenv, snapshot_yaml): +@pytest.mark.parametrize( + "key", + [ + "dbMediaHandlers", + "dbRelationships", + "dbRepresentations", + "dbRoutines", + "dbTables", + "dbTimezones", + ], +) +def test_schema_cache_snapshot(baseenv, key, snapshot_yaml): "Dump of schema cache should match snapshot." schema_cache = yaml.load(cli(["--dump-schema"], env=baseenv), Loader=yaml.Loader) - formatted = yaml.dump(schema_cache, encoding="utf8", allow_unicode=True) + formatted = yaml.dump( + schema_cache[key], + encoding="utf8", + allow_unicode=True, + Dumper=yaml.SafeDumper if key == "dbTimezones" else ExtraNewLinesDumper, + ) assert formatted == snapshot_yaml