greatexpectationslabs / cooper-pair

Cooper Pair is a Python library to simplify programmatic access to the Allotrope GraphQL API.
Apache License 2.0
0 stars 0 forks source link

Better asserts in `cooper-pair` #10

Open abegong opened 6 years ago

abegong commented 6 years ago

There are lots of places in the unit tests where we do this: assert pair.add_dataset_from_pandas_df(pandas_df, 1, filename='etp_participant_data')

This verifies that the code runs without error, but says nothing about the content of the response.

In this case, the response is something like:

{
  "dataset": {
    "id": "RGF0YXNldDoxMzE=",
    "project": {
      "id": "UHJvamVjdDox"
    },
    "createdBy": {
      "id": "VXNlcjo3"
    },
    "filename": "etp_participant_data_orgID-None",
    "s3Key": "ef1de6a6-a3f3-4dc5-9ccd-6c79880f4c0detp_participant_data_orgID-None",
    "organization": null
  }
}

The structure of this response would make a good test case. Most of the specific values (e.g. filename, s3Key, all the ids, etc.) would not.

It would be great to have a function to assert that two nested dictionaries share the same keys. We could use it all over test_pair.py to:

  1. Make the unit tests more thorough, but testing WHAT gets returned not just IF something gets returned.
  2. Make the unit tests more informative, by including snippets of returned data.
abegong commented 6 years ago

jsonschema could do 1 but not 2.