-
Notifications
You must be signed in to change notification settings - Fork 0
/
pytest-bdd.py
55 lines (34 loc) · 1.28 KB
/
pytest-bdd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from pytest_bdd import scenario, given, when, then, steps
import pytest
from api_wrapper import ApiWrapper
@scenario('bdd_tests.feature', 'Happy day cases of bears api')
def test_publish():
pass
@pytest.fixture
def api_wrapper():
instance = ApiWrapper()
yield instance
@given(u'there are no bears stored')
def check_no_bears(api_wrapper):
bears = api_wrapper.get_all_bears()
print(bears)
assert bears == []
@then(u'there are no bears stored')
def check_no_bears_then(api_wrapper):
check_no_bears(api_wrapper)
@given(u'the api wrapper object is created')
def create_api_wrapper(api_wrapper):
if not api_wrapper:
raise ConnectionError("not setup the api object")
@when(u'a bear is created with the following info')
def create_bear_table(api_wrapper):
print(f"Values: {context.table[0]['bear_type']}")
response = context.api_wrapper.add_a_bear(bear_type=context.table[0]["bear_type"],
name=context.table[0]["name"],
description=context.table[0]["description"],
age=context.table[0]["age"])
print(response)
assert response == 200
@then(u'when the full bears list is requested, the bear is in the list')
def step_impl(context):
pass