本文整理汇总了Python中tests.stetl_test_case.StetlTestCase类的典型用法代码示例。如果您正苦于以下问题:Python StetlTestCase类的具体用法?Python StetlTestCase怎么用?Python StetlTestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StetlTestCase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_execute
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')
示例2: test_execute
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])
示例3: test_execute
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)
示例4: test_execute
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
result = sys.stdout.getvalue().strip().split('\n')
self.assertEqual(len(result), 431)
示例5: test_execute
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')
示例6: test_execute
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")
示例7: test_execute
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!')
示例8: test_execute
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'}")
示例9: test_execute
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()
# Invoke first component of chain
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, contents)
示例10: test_execute
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)
示例11: test_no_namespace
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)
示例12: test_format_args
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!')
示例13: test_instance
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))
示例14: test_execute
def test_execute(self):
chain = StetlTestCase.get_chain(self.etl)
chain.run()
# 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))
# Compare temp file to input file byte by byte
section = StetlTestCase.get_section(chain)
orig_file_path = self.etl.configdict.get(section, 'file_path')
with open(file_path, 'rb') as f:
file = f.read()
with open(orig_file_path, 'rb') as f:
orig_file = f.read()
self.assertEqual(file, orig_file)
# Remove temp file
os.remove(file_path)
示例15: test_execute
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)