Skip to content

Commit

Permalink
WIP: add flag to detect if UPS is on or off in accept tests (#341)
Browse files Browse the repository at this point in the history
* add flag - i statement to run tests if ups is present or not

* test_decide_feature now has upn and no-ups version

* add a different function url_points_to_cluster

* add ups flag to test_decide__flag_key_parameter

* fix expected response

* add ups toggle to tests for ups save

* revert changes to test_ups.py file, readme addition

* cleanup

* separate ups and non-ups tests, remove if condition
  • Loading branch information
Mat001 authored Apr 20, 2022
1 parent 43fc70a commit 1a31b04
Show file tree
Hide file tree
Showing 4 changed files with 227 additions and 65 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@ test-acceptance:
make setup && \
make run & \
bash scripts/wait_for_agent_to_start.sh && \
pytest -vv -rA --diff-symbols tests/acceptance/test_acceptance/ -k "$(TEST)" --host "$(MYHOST)" && \
pytest -vv -rA --diff-symbols tests/acceptance/test_acceptance/ \
-k "not test_decide__feature_no_ups and not test_decide__flag_key_parameter_no_ups" --host "$(MYHOST)" && \
make stop
5 changes: 2 additions & 3 deletions tests/acceptance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ Run tests

You can point `MYHOST` to any URL where agent service is located.

If you want to run an individual test add TEST variable in front like so:
`TEST="test_activate__disable_tracking" MYHOST="http://localhost:8080" make test-acceptance`
The TEST variable is based on Pytest's -k pattern matching flag so you can provide a full name of the test to only run that test, or a partial name which will run all tests that match that name pattern.
Tests contain a few tests that don't support user profile service. Those tests are intended to be used
by Optimizely at a different place and are therefore excluded from the main test run.
18 changes: 10 additions & 8 deletions tests/acceptance/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@

YAML_FILE_PATH = os.getenv('OPENAPI_YAML_PATH', 'api/openapi-spec/openapi.yaml')

spec_dict = None
with open(YAML_FILE_PATH, 'r') as stream:
try:
spec_dict = yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)

spec = create_spec(spec_dict)
def parse_yaml(path):
with open(path, 'r') as stream:
try:
return yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)


spec = create_spec(parse_yaml(YAML_FILE_PATH))


def get_random_string():
Expand All @@ -43,7 +45,7 @@ def get_random_string():

def get_pretty_json(dictionary, spaces=4):
"""
Makes JSON output prettuer and readable.
Makes JSON output prettier and readable.
:return: stringified JSON
"""
return json.dumps(dictionary, indent=spaces)
Expand Down
Loading

0 comments on commit 1a31b04

Please sign in to comment.