def setUp(self): self.target = http.target('http://blazedemo.com', auto_assert_ok=False)
from unittest import TestCase from apiritif import http target = http.target("http://blazedemo.com") target.use_cookies(False) target.auto_assert_ok(False) class TestSimple(TestCase): def test_blazedemo_index(self): response = target.get("/") response.assert_ok() def test_blazedemo_not_found(self): response = target.get("/not-found") response.assert_failed()
import logging import time import unittest from apiritif import http, transaction, transaction_logged target = http.target('https://jsonplaceholder.typicode.com') target.keep_alive(True) target.auto_assert_ok(False) target.use_cookies(True) class TestRequests(unittest.TestCase): # will produce test-case sample with one sub-sample def test_1_single_request(self): target.get('/') # will produce test-case sample with two sub-samples def test_2_multiple_requests(self): target.get('/') target.get('/2') # won't produce test-case sample, only transaction def test_3_toplevel_transaction(self): with transaction("Transaction"): target.get('/') target.get('/2') # won't produce test-case sample, only "Tran Name" # will also will skip "GET /" request, as it's not in the transaction. def test_4_mixed_transaction(self):
import logging import time import unittest import threading import apiritif from apiritif import http, transaction, transaction_logged, smart_transaction target = http.target('https://httpbin.org') target.keep_alive(True) target.auto_assert_ok(False) target.use_cookies(True) class TestRequests(unittest.TestCase): # will produce test-case sample with one sub-sample def test_1_single_request(self): target.get('/') # will produce test-case sample with two sub-samples def test_2_multiple_requests(self): target.get('/') target.get('/2') # won't produce test-case sample, only transaction def test_3_toplevel_transaction(self): with transaction("Transaction"): target.get('/') target.get('/2') # won't produce test-case sample, only "Tran Name"