generated from GovStackWorkingGroup/bb-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from GovStackWorkingGroup/behave
TECH-757: Migrate pytest-bdd to behave
- Loading branch information
Showing
17 changed files
with
83 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ version: 2.1 | |
setup: true | ||
|
||
orbs: | ||
test-harness: govstack-working-group/[email protected].5 | ||
test-harness: govstack-working-group/[email protected].6 | ||
|
||
# Invoke jobs via workflows | ||
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows | ||
|
@@ -21,4 +21,6 @@ workflows: | |
- test-harness/execute-tests: | ||
requires: | ||
- test-harness/create-config | ||
context: | ||
- bb-testing | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
FROM python:3.8 | ||
FROM python:3.10 | ||
|
||
COPY requirements.txt /requirements.txt | ||
|
||
RUN pip install -r /requirements.txt | ||
|
||
COPY . /tests | ||
COPY ./features /tests | ||
|
||
WORKDIR /tests/ | ||
|
||
#ENV CONSENTBB_API_HOST=localhost:8080 | ||
ENV CONSENTBB_API_HOST=localhost:8888 | ||
ENV CONSENTBB_API_PATH=/api | ||
|
||
CMD pytest --cucumberjson=/data/results.json /tests | ||
CMD behave --format json --summary --outfile=/data/results.json /tests |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import requests | ||
|
||
|
||
from behave import fixture, use_fixture | ||
|
||
|
||
@fixture | ||
def client(context): | ||
url = "https://{}{}".format( | ||
os.environ["CONSENTBB_API_HOST"], | ||
os.environ["CONSENTBB_API_PATH"] | ||
) | ||
|
||
context.session = requests.Session() | ||
|
||
# Save our api_url on the session. This property doesn't have anything at all to do with | ||
# the requests library, it's our own little thing :) | ||
context.session.api_url = url | ||
|
||
# We are self-signing SSL certificates in example deployments. | ||
context.session.verify = False | ||
yield context.session | ||
context.session.close() | ||
|
||
|
||
def before_all(context): | ||
use_fixture(client, context,) |
1 change: 1 addition & 0 deletions
1
...gherkin/features/something_exists.feature → test/gherkin/features/smoke.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@method=GET @endpoint=/service/policy/{policyId}/ | ||
Feature: The Consent Building Block exists | ||
|
||
@smoke | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import json | ||
import os | ||
|
||
from behave import given, when, then | ||
|
||
|
||
@given("A URL of a Consent Building Block instance") | ||
def step_impl(context): | ||
|
||
# We just use the API url given from the context, a more advanced | ||
# setup could try other API base urls. | ||
assert context.session.api_url | ||
context.api_url = context.session.api_url | ||
|
||
|
||
@when("I call a basic public API endpoint") | ||
def step_impl(context): | ||
""" | ||
This method currently calls a well-known API with fixture data (policy ID=1). | ||
However, we would like to call a GovStack status API instead, but this isn't yet a feature that has | ||
been developed across building blocks. | ||
""" | ||
context.response = context.session.get( | ||
os.path.join(context.api_url, "service/policy/1/") | ||
) | ||
|
||
|
||
@then("I get some valid JSON data back") | ||
def step_impl(context): | ||
if not context.response.status_code == 200: | ||
raise AssertionError(f"Got status code {context.response.status_code}\n\nContent:\n{context.response.content}") | ||
response_data = json.loads(context.response.content) | ||
assert isinstance(response_data, dict) | ||
# This is the Policy object | ||
assert isinstance(response_data["policy"], dict) | ||
# This is the Revision object | ||
assert isinstance(response_data["revision"], dict) |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
pytest | ||
pytest-bdd | ||
requests | ||
behave>=1.2.6,<1.3 | ||
requests>=2.31.0,<3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.