def test_result_file_exists(self): engine = FlatFileEngine(self.config_dict) with patch('os.path.exists') as patched_exists: patched_exists.return_value = True self.assertEqual(engine.result(True), self.config_dict['path'])
def test_format_data(self): engine = FlatFileEngine(self.config_dict) ascii_str = str('Test') unicode_str = engine.format_data(ascii_str) self.assertTrue(isinstance(ascii_str, str)) self.assertTrue(isinstance(unicode_str, unicode))
def test_write(self): engine = FlatFileEngine(self.config_dict) test_data = 'Test' m = mock_open() with patch('railgun.engines.flatfile.open', m, create=True): engine.write(test_data) handle = m() handle.write.assert_called_once_with(test_data)
def test_ready(self): engine = FlatFileEngine(self.config_dict) self.assertTrue(engine.ready(True))