Skip to content

Commit

Permalink
Refactor test_requirements_files func
Browse files Browse the repository at this point in the history
  • Loading branch information
kenwade4 committed Mar 15, 2022
1 parent 8f16aba commit a83f1e3
Showing 1 changed file with 73 additions and 148 deletions.
221 changes: 73 additions & 148 deletions tests/test_packaging.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import os.path
from glob import glob

import requirements as rp

from great_expectations.data_context.util import file_relative_path
Expand All @@ -6,161 +9,83 @@
def test_requirements_files():
"""requirements.txt should be a subset of requirements-dev.txt"""

with open(file_relative_path(__file__, "../requirements.txt")) as req:
requirements = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev.txt")) as req:
requirements_dev = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-lite.txt")) as req:
requirements_dev_lite = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-contrib.txt")) as req:
requirements_dev_contrib = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-test.txt")) as req:
requirements_dev_test = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-spark.txt")) as req:
requirements_dev_spark = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(
file_relative_path(__file__, "../requirements-dev-sqlalchemy.txt")
) as req:
requirements_dev_sqlalchemy = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-arrow.txt")) as req:
requirements_dev_arrow = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-athena.txt")) as req:
requirements_dev_athena = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-azure.txt")) as req:
requirements_dev_azure = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-bigquery.txt")) as req:
requirements_dev_bigquery = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-dremio.txt")) as req:
requirements_dev_dremio = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-excel.txt")) as req:
requirements_dev_excel = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}
req_set_dict = {}
for req_file in glob(
file_relative_path(__file__, os.path.join("..", "requirements*.txt"))
):
key = req_file.rsplit(os.path.sep, 1)[-1]
with open(req_file) as f:
req_set_dict[key] = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(f)
}

with open(file_relative_path(__file__, "../requirements-dev-mssql.txt")) as req:
requirements_dev_mssql = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}
assert req_set_dict["requirements.txt"] <= req_set_dict["requirements-dev.txt"]

with open(file_relative_path(__file__, "../requirements-dev-mysql.txt")) as req:
requirements_dev_mysql = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-pagerduty.txt")) as req:
requirements_dev_pagerduty = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(
file_relative_path(__file__, "../requirements-dev-postgresql.txt")
) as req:
requirements_dev_postgresql = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-redshift.txt")) as req:
requirements_dev_redshift = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-snowflake.txt")) as req:
requirements_dev_snowflake = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

with open(file_relative_path(__file__, "../requirements-dev-teradata.txt")) as req:
requirements_dev_teradata = {
f'{line.name}{"".join(line.specs[0])}' for line in rp.parse(req)
}

assert requirements <= requirements_dev

assert requirements_dev_contrib | requirements_dev_lite == requirements_dev_test

assert requirements_dev_lite & requirements_dev_spark == set()
assert (
req_set_dict["requirements-dev-contrib.txt"]
| req_set_dict["requirements-dev-lite.txt"]
== req_set_dict["requirements-dev-test.txt"]
)

assert requirements_dev_spark & requirements_dev_sqlalchemy == set()
assert (
req_set_dict["requirements-dev-lite.txt"]
& req_set_dict["requirements-dev-spark.txt"]
== set()
)

assert requirements_dev_lite & requirements_dev_contrib == set()
assert (
req_set_dict["requirements-dev-spark.txt"]
& req_set_dict["requirements-dev-sqlalchemy.txt"]
== set()
)

assert (
requirements_dev_lite
| requirements_dev_athena
| requirements_dev_azure
| requirements_dev_bigquery
| requirements_dev_dremio
| requirements_dev_mssql
| requirements_dev_mysql
| requirements_dev_postgresql
| requirements_dev_redshift
| requirements_dev_snowflake
| requirements_dev_teradata
) == requirements_dev_sqlalchemy
req_set_dict["requirements-dev-lite.txt"]
& req_set_dict["requirements-dev-contrib.txt"]
== set()
)

assert (
requirements
| requirements_dev_contrib
| requirements_dev_sqlalchemy
| requirements_dev_arrow
| requirements_dev_excel
| requirements_dev_pagerduty
| requirements_dev_spark
) == requirements_dev
req_set_dict["requirements-dev-lite.txt"]
| req_set_dict["requirements-dev-athena.txt"]
| req_set_dict["requirements-dev-azure.txt"]
| req_set_dict["requirements-dev-bigquery.txt"]
| req_set_dict["requirements-dev-dremio.txt"]
| req_set_dict["requirements-dev-mssql.txt"]
| req_set_dict["requirements-dev-mysql.txt"]
| req_set_dict["requirements-dev-postgresql.txt"]
| req_set_dict["requirements-dev-redshift.txt"]
| req_set_dict["requirements-dev-snowflake.txt"]
| req_set_dict["requirements-dev-teradata.txt"]
) == req_set_dict["requirements-dev-sqlalchemy.txt"]

assert requirements_dev - (
requirements
| requirements_dev_lite
| requirements_dev_contrib
| requirements_dev_spark
| requirements_dev_sqlalchemy
| requirements_dev_arrow
| requirements_dev_athena
| requirements_dev_azure
| requirements_dev_bigquery
| requirements_dev_dremio
| requirements_dev_excel
| requirements_dev_mssql
| requirements_dev_mysql
| requirements_dev_pagerduty
| requirements_dev_postgresql
| requirements_dev_redshift
| requirements_dev_snowflake
| requirements_dev_teradata
assert (
req_set_dict["requirements.txt"]
| req_set_dict["requirements-dev-contrib.txt"]
| req_set_dict["requirements-dev-sqlalchemy.txt"]
| req_set_dict["requirements-dev-arrow.txt"]
| req_set_dict["requirements-dev-excel.txt"]
| req_set_dict["requirements-dev-pagerduty.txt"]
| req_set_dict["requirements-dev-spark.txt"]
) == req_set_dict["requirements-dev.txt"]

assert req_set_dict["requirements-dev.txt"] - (
req_set_dict["requirements.txt"]
| req_set_dict["requirements-dev-lite.txt"]
| req_set_dict["requirements-dev-contrib.txt"]
| req_set_dict["requirements-dev-spark.txt"]
| req_set_dict["requirements-dev-sqlalchemy.txt"]
| req_set_dict["requirements-dev-arrow.txt"]
| req_set_dict["requirements-dev-athena.txt"]
| req_set_dict["requirements-dev-azure.txt"]
| req_set_dict["requirements-dev-bigquery.txt"]
| req_set_dict["requirements-dev-dremio.txt"]
| req_set_dict["requirements-dev-excel.txt"]
| req_set_dict["requirements-dev-mssql.txt"]
| req_set_dict["requirements-dev-mysql.txt"]
| req_set_dict["requirements-dev-pagerduty.txt"]
| req_set_dict["requirements-dev-postgresql.txt"]
| req_set_dict["requirements-dev-redshift.txt"]
| req_set_dict["requirements-dev-snowflake.txt"]
| req_set_dict["requirements-dev-teradata.txt"]
) <= {"numpy>=1.21.0", "scipy>=1.7.0"}

0 comments on commit a83f1e3

Please sign in to comment.