summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorThomas Rueckstiess <thomas@rueckstiess.net>2015-01-06 12:56:20 +1100
committerThomas Rueckstiess <thomas@rueckstiess.net>2015-01-06 16:01:47 +1100
commit9870fac5cc06afbf2afcb2c808441f5355446779 (patch)
tree47487f38a5feb5fbb4f6c304e81c1768dc694cc3 /tools
parente16b5e1f677c8eb38ebd5a935cf4abf03d24acc5 (diff)
downloadmongo-9870fac5cc06afbf2afcb2c808441f5355446779.tar.gz
added test for --json, fixed issue running nosetests from ./test.
Diffstat (limited to 'tools')
-rw-r--r--tools/test/test_wtstats.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/tools/test/test_wtstats.py b/tools/test/test_wtstats.py
index bd0481bb59c..2a79d776528 100644
--- a/tools/test/test_wtstats.py
+++ b/tools/test/test_wtstats.py
@@ -25,7 +25,11 @@ def helper_delete_file(filename):
def helper_cleanup():
""" delete all html files in test directory """
- for f in glob.glob('./test/*.html'):
+ patterns = ('*.json', '*.html', '*.pyc')
+ matches = []
+ for p in patterns:
+ matches.extend(glob.glob(os.path.join(test_dir, p)))
+ for f in matches:
helper_delete_file(f)
@@ -232,19 +236,32 @@ def test_list_option():
@with_setup(setUp, tearDown)
+def test_json_option():
+ """ wtstats should additionally output json file with --json """
+
+ outfile = '_test_output_file.html'
+ helper_run_with_fixture({'--output': outfile, '--json': None})
+ data_html = helper_get_json_from_file(outfile)
+ with open(os.path.join(test_dir, '_test_output_file.json'), 'r') as jsonfile:
+ data_json = json.load(jsonfile)
+
+ assert data_html == data_json
+
+
+@with_setup(setUp, tearDown)
def test_all_option():
""" wtstats should create grouped html files with --all """
outfile = 'mystats.html'
helper_run_with_fixture({'--output': outfile, '--all': None})
- files = glob.glob('./test/*.html')
+ files = glob.glob(os.path.join(test_dir, '*.html'))
# test some expected files
assert len(files) > 1
- assert './test/mystats.transaction.html' in files
- assert './test/mystats.group.system.html' in files
- assert './test/mystats.html' in files
+ assert os.path.join(test_dir, 'mystats.transaction.html') in files
+ assert os.path.join(test_dir, 'mystats.group.system.html') in files
+ assert os.path.join(test_dir, 'mystats.html') in files
data = helper_get_json_from_file('mystats.transaction.html')