xnuinside / simple-ddl-parser

Simple DDL Parser to parse SQL (HQL, TSQL, AWS Redshift, BigQuery, Snowflake and other dialects) ddl files to json/python dict with full information about columns: types, defaults, primary keys, etc. & table properties, types, domains, etc.
MIT License
179 stars 40 forks source link

Parametrize tests #188

Closed mkaraev closed 1 year ago

mkaraev commented 1 year ago

Here is an example of how tests could be parametrized.

Pros:

  1. Makes tests easy to read
  2. Reduces the tests codebase

Possible cons:

  1. A lot of new files with test data in fixtures/ directory. For the changed test the number of new files would be ~100.
  2. Could increase time to find out what data is used for a particular tests case

A possible improvement to minimize cons: We can create fixtures/ddl/and fixtures/parsed/ directories to separate SQL files from parsed JSON files. But still, it will be challenging to keep all fixture files for all tests. We can put each test module in its on directory with particular fixtures used in this test module. The code inside of test modules will be reduced but the number of files and hierarchy of the tests/ directory will increase.

tests/
  test_simple_ddl_parser/
     fixtures/
        ddl/
          a.sql
          b.sql
        parsed/
         a.json
         b.json
     test_simple_ddl_parser.py