Spaces Data
Minimal test - lines (29, 84)
path: .spaces[0].metrics.loc.sloc
old: 55.0
new: 56.0
path: .spaces[0].metrics.loc.cloc
old: 6.0
new: 7.0
path: .spaces[0].metrics.mi.mi_original
old: 66.95237508103205
new: 66.66047529188864
path: .spaces[0].metrics.mi.mi_sei
old: 45.88232016548389
new: 47.01619940755463
path: .spaces[0].metrics.mi.mi_visual_studio
old: 39.15343571990178
new: 38.98273408882377
Code
class TestExport(unittest.TestCase):
"""Unit tests for the export module.
"""
_CLEAN_TMP_OUTPUT = True
def setUp(self):
"""Creates temporary data to export."""
self._tmp_path = tempfile.mkdtemp()
# Run a fake experiment to produce data to export.
simulator = simulation.ApmModuleSimulator(
test_data_generator_factory=(
test_data_generation_factory.TestDataGeneratorFactory(
aechen_ir_database_path='',
noise_tracks_path='',
copy_with_identity=False)),
evaluation_score_factory=(
eval_scores_factory.EvaluationScoreWorkerFactory(
polqa_tool_bin_path=os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'fake_polqa'))),
ap_wrapper=audioproc_wrapper.AudioProcWrapper(
audioproc_wrapper.AudioProcWrapper.DEFAULT_APM_SIMULATOR_BIN_PATH),
evaluator=evaluation.ApmModuleEvaluator())
simulator.Run(
config_filepaths=['apm_configs/default.json'],
capture_input_filepaths=[
os.path.join(self._tmp_path, 'pure_tone-440_1000.wav'),
os.path.join(self._tmp_path, 'pure_tone-880_1000.wav'),
],
test_data_generator_names=['identity', 'white_noise'],
eval_score_names=['audio_level_peak', 'audio_level_mean'],
output_dir=self._tmp_path)
# Export results.
p = collect_data.InstanceArgumentsParser()
args = p.parse_args(['--output_dir', self._tmp_path])
src_path = collect_data.ConstructSrcPath(args)
self._data_to_export = collect_data.FindScores(src_path, args)
def tearDown(self):
"""Recursively deletes temporary folders."""
if self._CLEAN_TMP_OUTPUT:
shutil.rmtree(self._tmp_path)
else:
logging.warning(self.id() + ' did not clean the temporary path ' + (
self._tmp_path))
def testCreateHtmlReport(self):
fn_out = os.path.join(self._tmp_path, 'results.html')
exporter = export.HtmlExport(fn_out)
exporter.Export(self._data_to_export)
document = pq.PyQuery(filename=fn_out)
self.assertIsInstance(document, pq.PyQuery)
# TODO(alessiob): Use PyQuery API to check the HTML file.
Minimal test - lines (77, 84)
path: .spaces[0].spaces[2].metrics.mi.mi_sei
old: 85.85860236133024
new: 108.77496707429948
path: .spaces[0].spaces[2].metrics.mi.mi_original
old: 111.91390412935166
new: 109.7506955688344
path: .spaces[0].spaces[2].metrics.mi.mi_visual_studio
old: 65.44672756102436
new: 64.18169331510784
path: .spaces[0].spaces[2].metrics.loc.cloc
old: 0.0
new: 1.0
path: .spaces[0].spaces[2].metrics.loc.sloc
old: 7.0
new: 8.0
Code
def testCreateHtmlReport(self):
fn_out = os.path.join(self._tmp_path, 'results.html')
exporter = export.HtmlExport(fn_out)
exporter.Export(self._data_to_export)
document = pq.PyQuery(filename=fn_out)
self.assertIsInstance(document, pq.PyQuery)
# TODO(alessiob): Use PyQuery API to check the HTML file.