371
371
results_dir = 'results'
372
372
name = 'testing_name'
373
373
generator = Mock()
374
375
with patch.object(
375
376
gpr, 'create_report_graph', return_value=image) as m_crg:
376
377
self.assertEqual(
378
379
gpr.generate_graph_image(
379
base_dir, results_dir, name, generator))
380
base_dir, results_dir, name, generator, graph_period))
380
381
m_crg.assert_called_once_with(
381
'/foo/test/results', '/foo/test/test-testing_name.png', generator)
383
'/foo/test/test-testing_name.png',
383
387
def test_generate_cpu_graph(self):
385
390
with self.patch_image_creation_ctx(image) as m_ggi:
386
391
self.assertEqual(
388
gpr.generate_cpu_graph_image('/foo'))
393
gpr.generate_cpu_graph_image('/foo', graph_period))
389
394
m_ggi.assert_called_once_with(
390
'/foo', 'aggregation-cpu-average', 'cpu', perf_graphing.cpu_graph)
396
'aggregation-cpu-max',
398
perf_graphing.cpu_graph,
392
401
def test_generate_memory_graph_calls_(self):
394
404
with self.patch_image_creation_ctx(image) as m_ggi:
395
405
self.assertEqual(
397
gpr.generate_memory_graph_image('/foo'))
407
gpr.generate_memory_graph_image('/foo', graph_period))
398
408
m_ggi.assert_called_once_with(
399
'/foo', 'memory', 'memory', perf_graphing.memory_graph)
412
perf_graphing.memory_graph,
401
415
def test_generate_network_graph(self):
403
418
with self.patch_image_creation_ctx(image) as m_ggi:
404
419
self.assertEqual(
406
gpr.generate_network_graph_image('/foo'))
421
gpr.generate_network_graph_image('/foo', graph_period))
407
422
m_ggi.assert_called_once_with(
408
'/foo', 'interface-eth0', 'network', perf_graphing.network_graph)
426
perf_graphing.network_graph,
410
429
def test_generate_mongo_query_graph(self):
412
432
with self.patch_image_creation_ctx(image) as m_ggi:
413
433
self.assertEqual(
415
gpr.generate_mongo_query_graph_image('/foo'))
435
gpr.generate_mongo_query_graph_image('/foo', graph_period))
416
436
m_ggi.assert_called_once_with(
417
'/foo', 'mongodb', 'mongodb', perf_graphing.mongodb_graph)
440
perf_graphing.mongodb_graph,
419
443
def test_generate_mongo_memory_graph(self):
421
446
with self.patch_image_creation_ctx(image) as m_ggi:
422
447
self.assertEqual(
424
gpr.generate_mongo_memory_graph_image('/foo'))
449
gpr.generate_mongo_memory_graph_image('/foo', graph_period))
425
450
m_ggi.assert_called_once_with(
428
453
'mongodb_memory',
429
perf_graphing.mongodb_memory_graph)
454
perf_graphing.mongodb_memory_graph,
431
457
def test_create_report_graph_returns_base_file_path(self):
432
458
"""The returned filepath should just be the basename."""
446
473
autospec=True, return_value=(start, end)) as m_gdp:
447
474
self.assertEqual(
448
475
output_file_base,
449
gpr.create_report_graph(rrd_dir, output_file, generator)
476
gpr.create_report_graph(
477
rrd_dir, output_file, generator, graph_period)
451
m_gdp.assert_called_once_with('/foo/example.rrd')
479
m_gdp.assert_called_once_with('/foo/example.rrd', graph_period)
452
480
m_list.assert_called_once_with(rrd_dir)
453
generator.assert_called_once_with(start, end, rrd_dir, output_file)
481
generator.assert_called_once_with(
482
start, end, rrd_dir, output_file)
456
485
class TestFindActualStart(TestCase):