-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add #34 Add BDD test for getting started page
- Loading branch information
1 parent
f22a206
commit 34e1235
Showing
5 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -2,3 +2,10 @@ | |
paths = features/ | ||
|
||
|
||
stderr_capture=False | ||
stdout_capture=False | ||
|
||
[behave.userdata] | ||
base_url = https://api.bb-consent.dev/v2 | ||
username = [email protected] | ||
password = qwerty123 |
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,76 @@ | ||
from behave import * | ||
import requests | ||
import json | ||
|
||
|
||
@given("the admin is logged into the Admin dashboard") | ||
def step_impl(context): | ||
username = context.config.userdata.get("username") | ||
password = context.config.userdata.get("password") | ||
base_url = context.config.userdata.get("base_url") | ||
data = { | ||
"username": username, | ||
"password": password, | ||
} | ||
url = base_url + "/onboard/admin/login" | ||
response = requests.post(url, json=data, verify=False) | ||
response_json = json.loads(response.content) | ||
context.access_token = response_json["accessToken"] | ||
|
||
|
||
@when("the admin updates the organization name, description, location, and policy URL") | ||
def step_impl(context): | ||
base_url = context.config.userdata.get("base_url") | ||
data = { | ||
"organisation": { | ||
"name": "Retail company", | ||
"description": "Retail electronic company", | ||
"sector": "Retail", | ||
"location": "Sweden", | ||
"policyUrl": "http://localhost.com", | ||
} | ||
} | ||
headers = {"Authorization": f"Bearer {context.access_token}"} | ||
url = base_url + "/onboard/organisation" | ||
response = requests.put(url, json=data, verify=False, headers=headers) | ||
response_json = json.loads(response.content) | ||
context.response = response | ||
|
||
|
||
@then("the organization information should be updated") | ||
def step_impl(context): | ||
assert context.response.status_code == 200 | ||
|
||
|
||
@when("the admin updates the organization logo and cover image") | ||
def step_impl(context): | ||
base_url = context.config.userdata.get("base_url") | ||
|
||
headers = { | ||
"Authorization": f"Bearer {context.access_token}" | ||
} | ||
logo_file_path = "assets/Sports.jpg" | ||
cover_image_file_path = "assets/Default_Cover_Image.jpg" | ||
|
||
# update logo image | ||
files = { | ||
"orgimage": ("Sports.jpg", open(logo_file_path, "rb")), | ||
} | ||
url = base_url + "/onboard/organisation/logoimage" | ||
response = requests.post(url, files=files, verify=False, headers=headers) | ||
context.response_logo_image = response | ||
|
||
# update cover image | ||
files = { | ||
"orgimage": ("Default_Cover_Image.jpg", open(cover_image_file_path, "rb")), | ||
} | ||
url = base_url + "/onboard/organisation/coverimage" | ||
response = requests.post(url, files=files, verify=False, headers=headers) | ||
context.response_cover_image = response | ||
|
||
|
||
@then("the logo and cover image should be updated") | ||
def step_impl(context): | ||
|
||
assert context.response_logo_image.status_code == 200 | ||
assert context.response_cover_image.status_code == 200 |
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,5 +1,6 @@ | ||
from behave import * | ||
import requests | ||
import json | ||
|
||
|
||
@given("an organization admin for Data4Diabetes organization") | ||
|
@@ -9,15 +10,20 @@ def step_impl(context): | |
|
||
@when("the admin logs into the Admin dashboard") | ||
def step_impl(context): | ||
username = context.config.userdata.get("username") | ||
password = context.config.userdata.get("password") | ||
base_url = context.config.userdata.get("base_url") | ||
data = { | ||
"username": "[email protected]", | ||
"password": "qwerty123", | ||
"username": username, | ||
"password": password, | ||
} | ||
url = "https://staging-consent-bb-api.igrant.io/v2" + "/onboard/admin/login" | ||
response = requests.post(url, json=data) | ||
url = base_url + "/onboard/admin/login" | ||
response = requests.post(url, json=data,verify=False) | ||
context.response = response | ||
|
||
|
||
@then("the admin should be able to access pages in the admin dashboard") | ||
def step_impl(context): | ||
response_json = json.loads(context.response.content) | ||
context.access_token = response_json["accessToken"] | ||
assert context.response.status_code == 200 |