Skip to content

Instantly share code, notes, and snippets.

@mtomwing
Last active August 29, 2015 14:00
Show Gist options
  • Save mtomwing/11395941 to your computer and use it in GitHub Desktop.
Save mtomwing/11395941 to your computer and use it in GitHub Desktop.
import json
import os
import httpretty
import pytest
from freeseer.plugins.importer.rss_feedparser import FeedParser
TEST_FEEDS = [
# (url, rss_file, json_file)
('http://fosslc.org/drupal/presentations_rss/summercamp2010', 'summercamp2010.rss', 'summercamp2010.json'),
]
@pytest.yield_fixture(params=TEST_FEEDS)
def feed(request):
url, rss_file, json_file = request.param
with open(os.path.join(os.path.dirname(__file__), rss_file)) as fd:
rss_data = fd.read()
with open(os.path.join(os.path.dirname(__file__), json_file)) as fd:
presentations = json.load(fd)['presentations']
httpretty.enable()
httpretty.register_uri(httpretty.GET, url, body=rss_data, content_type='application/rss+xml')
yield {
'url': url,
'presentations': presentations,
}
httpretty.disable()
def test_get_presentations(feed):
feedparser = FeedParser()
presentations = feedparser.get_presentations(feed['url'])
assert presentations == feed['presentations']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment