本文整理汇总了Python中tests.stetl_test_case.StetlTestCase.get_chain方法的典型用法代码示例。如果您正苦于以下问题:Python StetlTestCase.get_chain方法的具体用法?Python StetlTestCase.get_chain怎么用?Python StetlTestCase.get_chain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.stetl_test_case.StetlTestCase
的用法示例。
在下文中一共展示了StetlTestCase.get_chain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
result = sys.stdout.getvalue().strip().split('\n')
self.assertEqual(len(result), 431)
示例2: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
buffer_filter = chain.get_by_class(PacketBuffer)
packet_list = buffer_filter.packet_list
# most Packets are empty, but we need to find 2 filled with etree docs
doc_packet_list = []
for packet in packet_list:
if packet.data is not None:
doc_packet_list.append(packet)
# Assertion: we need to see 2 documents
self.assertEqual(len(doc_packet_list), 4)
namespaces={'gml': 'http://www.opengis.net/gml/3.2', 'top10nl': 'http://register.geostandaarden.nl/gmlapplicatieschema/top10nl/1.2.0'}
# Assertion: first doc has two FeatureMember elements with proper Namespaces
xml_doc1 = doc_packet_list[0].data
feature_elms = xml_doc1.xpath('/gml:FeatureCollectionT10NL/top10nl:FeatureMember', namespaces=namespaces)
self.assertEqual(len(feature_elms), 2)
# Assertion: last doc has one FeatureMember with proper Namespaces
last = len(doc_packet_list) - 1
xml_doc2 = doc_packet_list[last].data
feature_elms = xml_doc2.xpath('/gml:FeatureCollectionT10NL/top10nl:FeatureMember', namespaces=namespaces)
self.assertEqual(len(feature_elms), 1)
# Assertion: first doc has end_of_doc but not end_of_stream set
self.assertTrue(doc_packet_list[0].end_of_doc, msg='doc1: end_of_doc if False')
self.assertFalse(doc_packet_list[0].end_of_stream, msg='doc1: end_of_stream is True')
# Assertion: last doc has end_of_doc and end_of_stream set
self.assertTrue(doc_packet_list[last].end_of_doc, msg='doc2: end_of_doc if False')
self.assertTrue(doc_packet_list[last].end_of_stream, msg='doc2: end_of_stream if False')
示例3: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
buffer_filter = chain.get_by_class(PacketBuffer)
packet_list = buffer_filter.packet_list
self.assertEqual(packet_list[0].data.strip(), "foo/bar")
示例4: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
buffer_filter = chain.get_by_class(PacketBuffer)
packet_list = buffer_filter.packet_list
self.assertEqual(packet_list[0].data, 'Hello NLExtract!')
示例5: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
buffer_filter = chain.get_by_class(PacketBuffer)
packet_list = buffer_filter.packet_list
self.assertEqual(str(packet_list[0].data), "{'elemtype': 'BuildingInstallation', 'featurecount': '1162'}")
示例6: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
buffer_filter = chain.get_by_class(PacketBuffer)
packet_list = buffer_filter.packet_list
self.assertEqual(packet_list[0].data.get('elemtype'), "BuildingInstallation")
self.assertEqual(int(packet_list[0].data.get('featurecount')), 1162)
示例7: test_no_namespace
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_no_namespace(self):
chain = StetlTestCase.get_chain(self.etl, 2)
chain.run()
# Check the number of elements
result = sys.stdout.getvalue().strip().split('\n')
self.assertEqual(len(result), 3)
# Check the actual elements
self.check_execution_result(chain, result, False)
示例8: test_instance
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_instance(self):
chain = StetlTestCase.get_chain(self.etl)
splitter_comp = chain.first_comp.next
self.assertTrue(isinstance(splitter_comp, Splitter))
# The next is a list of multiple Outputs
self.assertEqual(len(splitter_comp.next), 2)
self.assertTrue(isinstance(splitter_comp.next[0], StandardOutput))
self.assertTrue(isinstance(splitter_comp.next[1], StandardOutput))
示例9: test_format_args
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_format_args(self):
chain = StetlTestCase.get_chain(self.etl, 1)
chain.first_comp.do_init()
packet = Packet()
packet.init()
packet.component = chain.first_comp
chain.first_comp.before_invoke(packet)
packet = chain.first_comp.invoke(packet)
self.assertEqual(packet.data, 'Hello NLExtract!')
示例10: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
buffer_filter = chain.get_by_class(PacketBuffer)
packet_list = buffer_filter.packet_list
# Two city records filtered out
self.assertEqual(len(packet_list[0].data), 2)
self.assertEqual(str(packet_list[0].data[0]['city']), "amsterdam")
self.assertEqual(str(packet_list[0].data[1]['city']), "otterlo")
示例11: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
result = sys.stdout.getvalue().split('\n')
# The total number of lines written to stdout is twice the number of lines in the text file,
# because the print statement is used. This causes an extra linebreak to written. The number
# to assert, is even one higher, because of the split statement above. The last "line" is an
# empty string.
self.assertEqual(len(result), 37)
示例12: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
# Result should be merged lines from both files
result = sys.stdout.getvalue().split('\n')
# Strip empty lines
result = [s for s in result if (s or len(s) > 0)]
# Total should be twice of linecount non-empty lines in input file
self.assertEqual(len(result), 36)
示例13: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self):
# Read content of input file
chain = StetlTestCase.get_chain(self.etl)
section = StetlTestCase.get_section(chain)
fn = self.etl.configdict.get(section, 'file_path')
with open(fn, 'r') as f:
contents = f.read()
self.etl.run()
self.assertGreater(len(sys.stdout.getvalue()), 0)
# Assert includes last linebreak from stdout, due to print function
self.assertEqual(sys.stdout.getvalue(), contents + '\n')
示例14: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self, mock_tx_execute):
# Read content of input file
chain = StetlTestCase.get_chain(self.etl)
section = StetlTestCase.get_section(chain)
fn = self.etl.configdict.get(section, 'file_path')
with open(fn, 'r') as f:
contents = f.read()
self.etl.run()
self.assertTrue(mock_tx_execute.called)
self.assertEqual(1, mock_tx_execute.call_count)
args, kwargs = mock_tx_execute.call_args
self.assertEqual(contents, args[1])
示例15: test_execute
# 需要导入模块: from tests.stetl_test_case import StetlTestCase [as 别名]
# 或者: from tests.stetl_test_case.StetlTestCase import get_chain [as 别名]
def test_execute(self, mock_after_chain_invoke):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
# ZIP file contains two GML files, both should be extracted; count is 3 because of final
# call, so the ZipFileExtractor can indicate that no more files can be found.
self.assertTrue(mock_after_chain_invoke.called)
self.assertEqual(3, mock_after_chain_invoke.call_count)
# Check if temp file exists
section = StetlTestCase.get_section(chain, 1)
file_path = self.etl.configdict.get(section, 'file_path')
self.assertTrue(os.path.exists(file_path))
os.remove(file_path)