Skip to content

Commit ef09664

Browse files
committed
test: add new BDD feature
1 parent 0381d36 commit ef09664

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

features/crud.feature

Lines changed: 0 additions & 9 deletions
This file was deleted.

features/rates.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Feature: The API to retireve the desired data
2+
Scenario Outline: When user calls the base path they should be greeted
3+
Given the user wants to invoke API "http://127.0.0.1:3000" URL
4+
When the user invokes the API
5+
Then the user should be greeted with <EXPECTEDRESPONSE>
6+
7+
Examples: Input Variables
8+
|EXPECTEDRESPONSE |
9+
|{"message":"Hello world!"}|
10+
11+
Scenario Outline: When user calls api to retrieve rates by passing a date range, origin and source code they should recieve the data
12+
Given the user wants to invoke API "http://127.0.0.1:3000/rates?date_from=2021-01-01&date_to=2021-01-31&orig_code=CNGGZ&dest_code=EETLL" URL
13+
When the user invokes the API
14+
Then the user should be greeted with <EXPECTEDRESPONSE>
15+
16+
Examples: Input Variables
17+
|EXPECTEDRESPONSE |
18+
|{"rates":[{"count":6,"day":"2021-01-31","price":1154.3333333333333},{"count":6,"day":"2021-01-30","price":1154.3333333333333},{"count":6,"day":"2021-01-29","price":1154.3333333333333},{"count":6,"day":"2021-01-28","price":1155},{"count":6,"day":"2021-01-27","price":1155},{"count":6,"day":"2021-01-26","price":1154.6666666666667},{"count":6,"day":"2021-01-25","price":1154.6666666666667},{"count":6,"day":"2021-01-24","price":1154.3333333333333},{"count":6,"day":"2021-01-23","price":1154.3333333333333},{"count":6,"day":"2021-01-22","price":1154.3333333333333},{"count":6,"day":"2021-01-21","price":1154.6666666666667},{"count":6,"day":"2021-01-20","price":1154.6666666666667},{"count":6,"day":"2021-01-19","price":1155},{"count":6,"day":"2021-01-18","price":1154.6666666666667},{"count":6,"day":"2021-01-17","price":1155},{"count":6,"day":"2021-01-16","price":1155},{"count":6,"day":"2021-01-15","price":1155},{"count":6,"day":"2021-01-14","price":1154.6666666666667},{"count":6,"day":"2021-01-13","price":1154.6666666666667},{"count":6,"day":"2021-01-12","price":1154.6666666666667},{"count":6,"day":"2021-01-11","price":1154.6666666666667},{"count":6,"day":"2021-01-10","price":1155},{"count":6,"day":"2021-01-09","price":1155},{"count":6,"day":"2021-01-08","price":1155},{"count":6,"day":"2021-01-07","price":1155},{"count":6,"day":"2021-01-06","price":1154},{"count":6,"day":"2021-01-05","price":1154},{"count":6,"day":"2021-01-04","price":1154.3333333333333},{"count":6,"day":"2021-01-03","price":1154.6666666666667},{"count":6,"day":"2021-01-02","price":1154.6666666666667},{"count":6,"day":"2021-01-01","price":1154.6666666666667}]}|

features/steps/step_def.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ def step_impl(context, expectedresponse):
1919
expected_greeting = json.loads(expectedresponse)
2020
assert (
2121
context.response.json() == expected_greeting
22-
), f"The expected response do not match, Expected: {expected_greeting} Actual: {context.response.json()}"
22+
), f"The response do not match, Expected: {expected_greeting} Actual: {context.response.json()}"

rates/rates.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ def get_rates():
7373
if not date_from or not date_to:
7474
raise BadRequest("Invalid date arguments")
7575
if orig_code and dest_code:
76-
return get_rates_using_codes
77-
(date_from, date_to, orig_code, dest_code)
76+
return get_rates_using_codes(date_from, date_to, orig_code, dest_code)
7877
raise BadRequest("Invalid location arguments")
7978

8079
def get_rates_using_codes(date_from, date_to, orig_code, dest_code):

0 commit comments

Comments
 (0)