• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python stetl_test_case.StetlTestCase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.stetl_test_case.StetlTestCase的典型用法代码示例。如果您正苦于以下问题:Python StetlTestCase类的具体用法?Python StetlTestCase怎么用?Python StetlTestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了StetlTestCase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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')
开发者ID:geopython,项目名称:stetl,代码行数:13,代码来源:test_standard_output.py


示例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])
开发者ID:geopython,项目名称:stetl,代码行数:14,代码来源:test_postgres_db_output.py


示例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)
开发者ID:geopython,项目名称:stetl,代码行数:14,代码来源:test_zip_file_extractor.py


示例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)
开发者ID:fsteggink,项目名称:stetl,代码行数:7,代码来源:test_csv_file_input.py


示例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')
开发者ID:fsteggink,项目名称:stetl,代码行数:35,代码来源:test_xml_assembler.py


示例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")
开发者ID:fsteggink,项目名称:stetl,代码行数:8,代码来源:test_command_exec_filter.py


示例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!')
开发者ID:fsteggink,项目名称:stetl,代码行数:8,代码来源:test_string_substitution_filter.py


示例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'}")
开发者ID:fsteggink,项目名称:stetl,代码行数:8,代码来源:test_regex_filter.py


示例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)
开发者ID:fsteggink,项目名称:stetl,代码行数:17,代码来源:test_string_file_input.py


示例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)
开发者ID:geopython,项目名称:stetl,代码行数:9,代码来源:test_regex_filter.py


示例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)
开发者ID:fsteggink,项目名称:stetl,代码行数:10,代码来源:test_xml_element_reader.py


示例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!')
开发者ID:fsteggink,项目名称:stetl,代码行数:10,代码来源:test_string_file_input.py


示例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))
开发者ID:fsteggink,项目名称:stetl,代码行数:10,代码来源:test_split_outputs.py


示例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)
开发者ID:fsteggink,项目名称:stetl,代码行数:20,代码来源:test_packet_writer.py


示例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)
开发者ID:fsteggink,项目名称:stetl,代码行数:11,代码来源:test_line_streamer_file_input.py


示例16: 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

        # 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")
开发者ID:fsteggink,项目名称:stetl,代码行数:11,代码来源:test_sieve.py


示例17: test_execute

    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)
开发者ID:fsteggink,项目名称:stetl,代码行数:12,代码来源:test_split_outputs.py


示例18: test_chain_assembly

    def test_chain_assembly(self):
        chain = StetlTestCase.get_chain(self.etl, assemble=False)
        chain.assemble()
        
        self.assertIsNotNone(chain.first_comp)
        self.assertIsNotNone(chain.cur_comp)

        self.assertIsNotNone(chain.first_comp.next)
        self.assertIsNone(chain.cur_comp.next)
        
        comp = chain.first_comp
        while comp.next is not None:
            comp = comp.next
            
        self.assertIs(comp, chain.cur_comp)
开发者ID:fsteggink,项目名称:stetl,代码行数:15,代码来源:test_chain.py


示例19: 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(len(packet_list), 1)

        # Inspect the result
        result = sys.stdout.getvalue().strip().split('\n')
        self.assertEqual(len(result), 6)
        
        pattern = r'<funcgeb id="[^"]+"/>'
        for i in range(2, 5):
            self.assertIsNotNone(re.match(pattern, result[i].strip()))
        self.assertTrue(result[1].strip().startswith('<dummy '))
        self.assertEqual(result[5].strip(), '</dummy>')
        
开发者ID:fsteggink,项目名称:stetl,代码行数:17,代码来源:test_xslt_filter.py


示例20: test_execute

 def test_execute(self):
     chain = StetlTestCase.get_chain(self.etl)
     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.assertIsNotNone(packet.data)
     self.assertIsInstance(packet.data, dict)
     self.assertTrue('menu' in packet.data)
     self.assertIsNotNone(packet.data['menu'])
     
     mydict = packet.data['menu']
     self.assertEqual(len(mydict), 3)
     self.assertTrue('id' in mydict)
     self.assertTrue('value' in mydict)
     self.assertTrue('popup' in mydict)
开发者ID:geopython,项目名称:stetl,代码行数:19,代码来源:test_json_file_input.py



注:本文中的tests.stetl_test_case.StetlTestCase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python support.assert_response_code函数代码示例发布时间:2022-05-27
下一篇:
Python test.main函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap