I am a newbie in python and currently learning how to write BDD tests using Lettuce (python). I have a very simple REST API based on Flask framework. I am bit stuck at the point in calling the functions under the app.route. For example my API looks like this
@app.route('/')
@app.route('/documentation')
def documentation():
return auto.html()
My lettuce tests are in a folder called features. This folder features has two files called test.feature and steps.py. test.feature contains the following features.
Feature: To test the root of API
Scenario: Call the root of the API
Given I have "/" or "/documentation"
When the user requests GET '/'
Then I response should be "GET HTTP/1.1 200".
definitions are written in steps.py file as follows.
@step('I have "([^"]*)" or "([^"]*)"')
def display_api(step, value, option):
print ('Attempting to display the API docs..')
-----
I am not sure how I can call @app.route('/') to run the tests and return the status 200 to lettuce or how will lettuce run the tests? I went through the lettuce documentation and I am still not able to figure out how to do a automated test to my REST API. Any suggestion or support will be much appreciated. Thanks in advance for your time.