class URLManifestTaskTest(unittest.TestCase): """Ensure manifest files are created appropriately.""" SOURCE_URL = 's3://foo/bar' MANIFEST_BASE_PATH = '/tmp/manifest' def setUp(self): self.task = URLManifestTask(urls=[self.SOURCE_URL]) self.expected_path = '{0}/{1}.manifest'.format(self.MANIFEST_BASE_PATH, hash(self.task)) @with_luigi_config( ('manifest', 'path', MANIFEST_BASE_PATH), ('manifest', 'lib_jar', '/tmp/foo.jar'), ('manifest', 'input_format', 'com.example.SimpleFormat') ) def test_annotate_output_target(self): target = self.task.output() self.assertEquals(target.path, self.expected_path) self.assertEquals(target.lib_jar, ['/tmp/foo.jar']) self.assertEquals(target.input_format, 'com.example.SimpleFormat') @with_luigi_config( ('manifest', 'path', MANIFEST_BASE_PATH), ('manifest', 'lib_jar', OPTION_REMOVED), ('manifest', 'input_format', OPTION_REMOVED) ) def test_parameters_not_configured(self): target = self.task.output() self.assertEquals(target.path, self.expected_path) self.assertFalse(hasattr(target, 'lib_jar')) self.assertFalse(hasattr(target, 'input_format')) @patch('edx.analytics.tasks.util.manifest.get_target_from_url') def test_manifest_file_construction(self, get_target_from_url_mock): fake_target = FakeTarget() get_target_from_url_mock.return_value = fake_target self.task.run() content = fake_target.buffer.read() self.assertEquals(content, self.SOURCE_URL + '\n') def test_requirements(self): self.assertItemsEqual(self.task.requires(), [UncheckedExternalURL(self.SOURCE_URL)])
class URLManifestTaskTest(unittest.TestCase): """Ensure manifest files are created appropriately.""" SOURCE_URL = 's3://foo/bar' MANIFEST_BASE_PATH = '/tmp/manifest' def setUp(self): self.task = URLManifestTask(urls=[self.SOURCE_URL]) self.expected_path = '{0}/{1}.manifest'.format(self.MANIFEST_BASE_PATH, hash(self.task)) @with_luigi_config( ('manifest', 'path', MANIFEST_BASE_PATH), ('manifest', 'lib_jar', '/tmp/foo.jar'), ('manifest', 'input_format', 'com.example.SimpleFormat')) def test_annotate_output_target(self): target = self.task.output() self.assertEquals(target.path, self.expected_path) self.assertEquals(target.lib_jar, ['/tmp/foo.jar']) self.assertEquals(target.input_format, 'com.example.SimpleFormat') @with_luigi_config(('manifest', 'path', MANIFEST_BASE_PATH), ('manifest', 'lib_jar', OPTION_REMOVED), ('manifest', 'input_format', OPTION_REMOVED)) def test_parameters_not_configured(self): target = self.task.output() self.assertEquals(target.path, self.expected_path) self.assertFalse(hasattr(target, 'lib_jar')) self.assertFalse(hasattr(target, 'input_format')) @patch('edx.analytics.tasks.util.manifest.get_target_from_url') def test_manifest_file_construction(self, get_target_from_url_mock): fake_target = FakeTarget() get_target_from_url_mock.return_value = fake_target self.task.run() content = fake_target.buffer.read() self.assertEquals(content, self.SOURCE_URL + '\n') def test_requirements(self): self.assertItemsEqual(self.task.requires(), [UncheckedExternalURL(self.SOURCE_URL)])
def setUp(self): self.task = URLManifestTask(urls=[self.SOURCE_URL]) self.expected_path = '{0}/{1}.manifest'.format(self.MANIFEST_BASE_PATH, hash(self.task))