def test_get_text(self): datalake_file = DatalakeFile(None, uri=self.uri, type=type) mock_func = create_autospec(datalake_file._get_text_from_remote, return_value=self.text_data) datalake_file._get_text_from_remote = mock_func text = datalake_file.get_text() self.assertEqual(text, self.text_data) mock_func.assert_called_once_with()
def test_get_text_using_cache(self): cache_dir = '{}/{}'.format(TEST_MOUNT_DIR, self.channel_id) os.makedirs(cache_dir, exist_ok=True) with open('{}/{}'.format(cache_dir, self.file_id), 'w') as f: f.write(self.text_data) datalake_file = DatalakeFile(None, uri=self.uri, type=type) mock_func = MagicMock() datalake_file._get_text_from_remote = mock_func text = datalake_file.get_text() self.assertEqual(text, self.text_data) mock_func.assert_not_called()