V
V
Vladimir Kozlovsky2014-10-21 13:18:08
Python
Vladimir Kozlovsky, 2014-10-21 13:18:08

Is there a module for testing REST API in Python 3?

I am looking for a module/framework for testing the REST API in Python 3. I want to be able to describe tasks in json/yaml, run them and get a colorful report in the console. Only a console library is required (I want autorun on commits) and only in Python 3.
For example:

[
    {
        "name": "Task 1",
        "request": {
            "url": "http://toster.ru/api/v1/questions/id231",
            "method": "get",
            "params": [
                "select": ["one", "two"],
                "public": "true"
            ],
            "headers": []
        },
        "response": {
            "body": {
                "title": "Существует модуль для тестирования REST API на Python 3?",
                "content": "Ищу модуль/фреймворк для тестирование REST API на Python 3. Хочу иметь..."
            },
            "headers": [
                "Content-Type": "application/json"
            ]
        }
    }
]

Is there such a thing or do I need to write my bike?
Thank you for your time.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kozlovsky, 2015-02-05
@vladkozlovsky

I answer the question myself: at the moment, the https://github.com/svanoort/pyresttest project is the most similar solution. Unfortunately it works on Python 2.

E
Egor Kazantsev, 2014-12-11
@saintbyte

Write your own =) I used bash for testing =)

#!/bin/bash
test_api()
{
wget -O"1111" "$1"
sleep 2
cat 1111
read
}
set +ue
set -x
TEST_DEVICE=0
TEST_DEVICE_ACCEPT=1
TEST_APP=0
if [ $TEST_DEVICE == 1 ]
then
test_api  http://127.0.0.1:5012/api/v1/device/json?id=123123123213
exit
test_api  http://127.0.0.1:5012/api/v1/device/json?id=123123123
test_api  http://127.0.0.1:5012/api/v1/device/json?id=12facacac3
test_api  "http://127.0.0.1:5012/api/v1/device/json?id=12facacac3&name=test device"

test_api  "http://127.0.0.1:5012/api/v1/device/json?id=12facacac3&name=test device111122223333444455556666777788889999000011112222333344
test_api  "http://127.0.0.1:5012/api/v1/device/json?id=22a0000015b8cc3c&name=test device111122223333444455556666777788889999000011112222
test_api  "http://127.0.0.1:5012/api/v1/device/json?id=ffffffffffffffff&name=test device111122223333444455556666777788889999000011112222
fi

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question