def test_benchmark_start(self, check_output, exists, action_set, relation_ids, relation_set, in_relation_hook, safe_load): exists.return_value = True check_output.return_value = "data" action_set.return_value = True relation_ids.return_value = ['benchmark:1'] in_relation_hook.return_value = True safe_load.side_effect = [METADATA] with patch_open() as (_open, _file): self.assertTrue(Benchmark.start()) _open.assert_called_with('/my_dir/metadata.yaml', 'r') relation_set.assert_called_once_with( relation_id='benchmark:1', relation_settings={'action_id': 'my_action'}) COLLECT_PROFILE_DATA = '/usr/local/bin/collect-profile-data' exists.assert_any_call(COLLECT_PROFILE_DATA) check_output.assert_any_call([COLLECT_PROFILE_DATA, 'my_action'])
def test_benchmark_start_oserror(self, action_set): action_set.side_effect = OSError('File not found') with patch_open() as (_open, _file): self.assertFalse(Benchmark.start())