def test_add_absolute_file(self): # Given file_extractor = FileExtractor(oozie_node=Element("fake"), params=self.default_params) # When file_extractor.add_file("/test_file") # Then self.assertEqual(file_extractor.files, ["/test_file"]) self.assertEqual(file_extractor.hdfs_files, ["hdfs:///test_file"])
def test_add_relative_file(self): # Given file_extractor = FileExtractor(oozie_node=Element("fake"), params=self.default_params) # When file_extractor.add_file("test_file") # Then self.assertEqual(file_extractor.files, ["test_file"]) self.assertEqual(file_extractor.hdfs_files, ["hdfs:///user/pig/examples/pig_test_node/test_file"])
def test_add_file_extra_hash(self): # Given file_extractor = FileExtractor(oozie_node=Element("fake"), params=self.default_params) # When with self.assertRaises(Exception) as context: file_extractor.add_file("/test_file#4rarear#") # Then self.assertEqual( "There should be maximum one '#' in the path /test_file#4rarear#", str(context.exception))
def test_add_multiple_files(self): # Given file_extractor = FileExtractor(oozie_node=Element("fake"), props=self.props) # When file_extractor.add_file("/test_file") file_extractor.add_file("test_file2") file_extractor.add_file("/test_file3") # Then self.assertEqual(file_extractor.files, ["/test_file", "test_file2", "/test_file3"]) self.assertEqual( file_extractor.hdfs_files, [ "hdfs:///test_file", "hdfs:///user/pig/examples/pig_test_node/test_file2", "hdfs:///test_file3" ], )
def test_add_hash_files(self): # Given file_extractor = FileExtractor(oozie_node=Element("fake"), params=self.default_params) # When file_extractor.add_file("/test_file#test3_link") file_extractor.add_file("test_file2#test_link") file_extractor.add_file("/test_file3") # Then self.assertEqual( file_extractor.files, ["/test_file#test3_link", "test_file2#test_link", "/test_file3"]) self.assertEqual( file_extractor.hdfs_files, [ "hdfs:///test_file#test3_link", "hdfs:///user/pig/examples/pig_test_node/test_file2#test_link", "hdfs:///test_file3", ], )