Beispiel #1
0
import datetime
import noseapp
from noseapp.ext.requests import RequestsEx, make_config
from requests import HTTPError
# setting up
endpoint = make_config()
endpoint.configure(
    base_url='http://127.0.0.1:5000/',
    key='127.0.0.1:5000'
)
endpoint.session_configure(
    always_return_json=True,
    raise_on_http_error=False
)
requests_ex = RequestsEx(endpoint)

# gather all tests
suite = noseapp.Suite('first_suite')

# setup for requests
api = requests_ex.get_endpoint_session('127.0.0.1:5000')


@suite.register
class TestCaseGetOne(noseapp.TestCase):
    """
        get request
    """
    def test_get_404(self):
        # check existence
        self.assertEqual(HTTPError(404).message, api.get('dictionary/123')['code'])
import json
import requests

suite = noseapp.Suite(__name__)

endpoint = make_config()
endpoint.configure(
	base_url='http://localhost:5000',
	key='httpbin'
)
endpoint.session_configure(
	always_return_json=True,
	raise_on_http_error=True
)

requests_ex = RequestsEx(endpoint)
api = requests_ex.get_endpoint_session('httpbin')
			  

@suite.register
class StepByStepCase(noseapp.ScreenPlayCase):	
	
	@noseapp.step(1, 'Delete old value if exist')
	def step_one(self):
		api.delete('dictionary/hello')       

	@noseapp.step(2, 'new value in dictionary')
	def step_two(self):
		api.post('dictionary', {'key': 'hello', 'value': 'Hello World'})

	@noseapp.step(3, 'put value')