-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
86 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from bombard.attr_dict import AttrDict | ||
|
||
|
||
class FakeArgs(AttrDict): | ||
threads = 1 | ||
timeout = 3 | ||
ms = False | ||
threshold = 1000 | ||
quiet = False | ||
dry = False | ||
verbose = False | ||
quiete = False | ||
log = None | ||
example = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import sys | ||
from contextlib import contextmanager | ||
from io import StringIO | ||
|
||
|
||
class CaptureOutput: | ||
def __enter__(self): | ||
self.out, self.err = StringIO(), StringIO() | ||
self.old_out, self.old_err = sys.stdout, sys.stderr | ||
sys.stdout, sys.stderr = self.out, self.err | ||
return self | ||
|
||
def __exit__(self, *args): | ||
sys.stdout, sys.stderr = self.old_out, self.old_err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from tests.stdout_contextmanager import CaptureOutput | ||
import unittest | ||
from bombard.main import campaign | ||
from tests.fake_args import FakeArgs | ||
from bombard.args import INIT_EXAMPLE, DIR_DESC_FILE_NAME, CAMPAIGN_FILE_NAME | ||
import os.path | ||
|
||
|
||
class TestShowFolder(unittest.TestCase): | ||
def setUp(self): | ||
if os.path.isfile(CAMPAIGN_FILE_NAME): | ||
os.remove(CAMPAIGN_FILE_NAME) | ||
|
||
def testShowFolder(self): | ||
with CaptureOutput() as captured: | ||
campaign(FakeArgs(init=True)) | ||
with open(f'bombard/examples/{DIR_DESC_FILE_NAME}') as desc: | ||
expected = desc.read() | ||
self.maxDiff = 1024 | ||
self.assertEqual( | ||
captured.out.getvalue().strip(), | ||
expected | ||
) | ||
|