def test_fetch(self):
# Create temp file to copy
file = open(os.path.join(self._copyFile.copy_from_prefix,
"%sbigFileXYZA" % tempfile.gettempprefix()), 'w')
file.write("Lots of interesting stuff")
file.close()
# Perform copy
interpolate_dict = {"project_identifier": tempfile.gettempprefix(),
"product_identifier": "bigFile",
"run_identifier": "XYZ"}
result_paths = self._copyFile.fetch(interpolate_dict=interpolate_dict)
# Test copied file exists and DataFile matches
self.assertEqual(len(result_paths), 1)
df = result_paths[0]
self.assertEqual(df.file_name, "%sbigFileXYZB" % tempfile.gettempprefix())
self.assertEqual(df.location, os.path.join(tempfile.gettempdir(),
"%sbigFileXYZB" % tempfile.gettempprefix()))
self.assertEqual(df.equipment, self._equipmentSequencer)
self.assertIs(filecmp.cmp(
os.path.join(tempfile.gettempdir(), "%sbigFileXYZA" % tempfile.gettempprefix()),
os.path.join(tempfile.gettempdir(), "%sbigFileXYZB" % tempfile.gettempprefix())), True)
# Clean up
os.remove(os.path.join(tempfile.gettempdir(), "%sbigFileXYZA" % tempfile.gettempprefix()))
os.remove(os.path.join(tempfile.gettempdir(), "%sbigFileXYZB" % tempfile.gettempprefix()))
评论列表
文章目录