def testSimplest(self): with CaptureOutput(capture=True) as captured: campaign(FakeArgs(example='simplest')) self.assertIn('GET jsonplaceholder.typicode.com/posts', captured.output) self.assertIn('GET jsonplaceholder.typicode.com/posts/1', captured.output)
def testVersion(self): with CaptureOutput() as captured: campaign(FakeArgs(version=True)) with open(f'bombard/LICENSE.txt') as license: self.assertIn(license.readline(), captured.output) self.assertIn(bombard.version(), captured.output)
def testRequest(self) -> None: bombardier.Bombardier(args=FakeArgs(), campaign_book={}).worker(1, TEST_AMMO) http_request.http.client.HTTPSConnection.request.assert_called_once_with( "GET", "/users", body=None, headers={"x-x": "json"}) http_request.http.client.HTTPSConnection.getresponse.assert_called_once( )
def testSimplest(self) -> None: with CaptureOutput(capture=True) as captured: campaign(FakeArgs(example="simplest")) self.assertIn("GET jsonplaceholder.typicode.com/posts", captured.output) self.assertIn("GET jsonplaceholder.typicode.com/posts/1", captured.output)
def testVersion(self) -> None: with CaptureOutput() as captured: campaign(FakeArgs(version=True)) with open("bombard/LICENSE.txt", encoding="utf8") as license: self.assertIn(license.readline(), captured.output) self.assertIn(bombard.version(), captured.output)
def testInitSimpleton(self): with CaptureOutput() as captured: campaign(FakeArgs(example='simpleton', init=True)) self.maxDiff = 1024 with open(f'bombard/examples/simpleton.yaml') as desc, open( f'{CAMPAIGN_FILE_NAME}', 'r') as init: self.assertIn(desc.read(), init.read())
def testInitDefault(self): with CaptureOutput() as captured: campaign(FakeArgs(init=True)) self.maxDiff = 1024 with open(f'bombard/examples/{INIT_EXAMPLE}') as ex, open( f'{CAMPAIGN_FILE_NAME}', 'r') as init: self.assertEqual(ex.read(), init.read())
def testShowFolder(self): with CaptureOutput() as captured: campaign(FakeArgs(examples=True)) self.maxDiff = 1024 with open(f'bombard/examples/{DIR_DESC_FILE_NAME}') as desc: self.assertIn( # do not check 1st line of output with the folder name markdown_for_terminal(desc.read()), captured.output)
def testInitSimpleton(self) -> None: with CaptureOutput(): campaign(FakeArgs(example="simpleton", init=True)) self.maxDiff = 1024 with open("bombard/examples/simpleton.yaml", encoding="utf8") as desc, open(f"{CAMPAIGN_FILE_NAME}", "r", encoding="utf8") as init: self.assertIn(desc.read(), init.read())
def testInitDefault(self) -> None: with CaptureOutput(): campaign(FakeArgs(init=True)) self.maxDiff = 1024 with open(f"bombard/examples/{INIT_EXAMPLE}", encoding="utf8") as ex, open(f"{CAMPAIGN_FILE_NAME}", "r", encoding="utf8") as init: self.assertEqual(ex.read(), init.read())
def testSimplest(self) -> None: with CaptureOutput(capture=True) as captured: start_campaign(FakeArgs(example="simplest"), EMPTY_BOOK) self.assertIn('You should have at least one of "prepare" and "ammo"', captured.output)
def testRequest(self): bombardier.Bombardier(args=FakeArgs()).worker(1, TEST_AMMO) http_request.http.client.HTTPSConnection.request.assert_called_once_with( 'GET', '/users', body=None, headers={'x-x': 'json'}) http_request.http.client.HTTPSConnection.getresponse.assert_called_once( )