示例#1
0
 def test_content_parser_get_block_items_podcast_item(self, podcasts_page_1_html, base_url):
     content = ContentParser(podcasts_page_1_html, base_url)
     blocks = content.get_block_items('.podcast-list .podcast-item')
     assert isinstance(blocks, list)
     assert len(blocks) == 3
     for block in blocks:
         assert isinstance(block, ContentParser)
示例#2
0
    def test_content_parser_get_block_parse_text_podcast_item(self, podcasts_page_1_html, base_url):
        right_data = [{
            'card-header': 'Podcast 1 Title',
            'card-body': 'Podcast 1 Themes\n                Podcast 1 Description.\n                podcast_1.mp3',
        }, {
            'card-header': 'Podcast 2 Title',
            'card-body': 'Podcast 2 Themes\n                Podcast 2 Description.\n                podcast_2.mp3',
        }, {
            'card-header': 'Podcast 3 Title',
            'card-body': 'Podcast 3 Themes\n                Podcast 3 Description.\n                podcast_3.mp3',
        }]

        content = ContentParser(podcasts_page_1_html, base_url)
        blocks = content.get_block_items('.podcast-list .podcast-item')
        for idx, block in enumerate(blocks):
            card_header = block.parse_text('.card-header')
            card_body = block.parse_text('.card-body')
            assert card_header == right_data[idx]['card-header']
            assert card_body == right_data[idx]['card-body']