Пример #1
0
 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)
Пример #2
0
    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)
Пример #3
0
 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(
     )
Пример #4
0
 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)
Пример #5
0
    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)
Пример #6
0
    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())
Пример #7
0
    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())
Пример #8
0
    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)
Пример #9
0
    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())
Пример #10
0
    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())
Пример #11
0
 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)
Пример #12
0
 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(
     )