PearsonEducation / Alarmageddon

Full-stack monitoring and alerting Python library.
Other
15 stars 10 forks source link

[Feature] add ability to wildcard arrays in json expectation #10

Closed curtisallen closed 8 years ago

curtisallen commented 8 years ago

What's this PR do?

Adds the ability to use a wildcard for an array index when using json expectations. Now you can do

HttpValidation.get("http://localhost/users").expect_json_property_value("users[*]", "Stephen")

Where should the reviewer start?

alarmageddon/validations/json_expectations.py

How should this be manually tested?

scripts/install

Any background context you want to provide?

Ran into a issue where a REST API I was testing didn't always preserve order when presenting json arrays. Sometimes you would get

{ "users":["Tim", "Scott"] }

others you'd get

{ "users":["Scott", "Tim"]}

This made using the json_expectations unreliable. The wildcard helps to alleviate this issue

Were the tests updated?

added a couple of tests for this functionality. For some reason scripts/install wouldn't work on my machine but .venv/bin/py.test -s tests/test_json_expectations.py worked like a charm.

scotthellman commented 8 years ago

Thanks Curtis! Looks good - I'll go ahead and merge it in.

curtisallen commented 8 years ago

Thanks!