def test_get_object(self, rf): project = factories.ProjectFactory() request = rf.get('/') feed = feeds.nomination_feed() obj = feed.get_object(request, project.project_slug) assert obj == project
def test_item_pubdate(self): project = factories.ProjectFactory() nom = factories.NominatedURLFactory(url_project=project) feed = feeds.nomination_feed() item_pubdate = feed.item_pubdate(nom) assert item_pubdate == nom.date
def test_subtitle(self): project = factories.ProjectFactory(project_name='Test Project') feed = feeds.nomination_feed() subtitle = feed.subtitle(project) assert subtitle == ('RSS feed for the most recently nominated URLs for Test Project. ' 'Includes newly added URLs and subsequent nominations of ' 'those URLs.')
def test_link(self, rf): project = factories.ProjectFactory(project_slug='test_project') request = rf.get('/') feed = feeds.nomination_feed() feed.get_object(request, project.project_slug) link = feed.link(project) assert link == '/nomination/test_project/feed/nominations/'
def test_item_link(self, rf): project = factories.ProjectFactory(project_slug='test_project') nom = factories.NominatedURLFactory(url_project=project, entity='http://www.example.com') request = rf.get('/') feed = feeds.nomination_feed() feed.get_object(request, project.project_slug) item_link = feed.item_link(nom) assert item_link == '/nomination/test_project/url/http://www.example.com/'
def test_item_description_returns_entity(self, rf): """If the URL has no description, return just the URL itself.""" project = factories.ProjectFactory() nom = factories.SURTFactory(url_project=project) request = rf.get('/') feed = feeds.nomination_feed() feed.get_object(request, project.project_slug) item_description = feed.item_description(nom) assert item_description == nom.entity
def test_item_title_returns_entity(self, rf): """If the URL has no site name or title on record, return the URL.""" project = factories.ProjectFactory() nom = factories.NominatedURLFactory(url_project=project) request = rf.get('/') feed = feeds.nomination_feed() feed.get_object(request, project.project_slug) item_title = feed.item_title(nom) assert item_title == nom.entity
def test_item_title(self, rf): project = factories.ProjectFactory() nom = factories.NominatedURLFactory(url_project=project) url = factories.URLFactory(url_project=project, entity=nom.entity, attribute='Site_Name') request = rf.get('/') feed = feeds.nomination_feed() feed.get_object(request, project.project_slug) item_title = feed.item_title(nom) assert item_title == url.value
def test_item_title_returns_url_title(self, rf): """If the url has no site name on record, return the title.""" project = factories.ProjectFactory() nom = factories.NominatedURLFactory(url_project=project) url = factories.URLFactory(url_project=project, entity=nom.entity, attribute='Title') request = rf.get('/') feed = feeds.nomination_feed() feed.get_object(request, project.project_slug) item_title = feed.item_title(nom) assert item_title == url.value
def test_items_returns_sorted_nominations(self): """Items returned should be sorted by item.date""" project = factories.ProjectFactory() noms = factories.NominatedURLFactory.create_batch(2, url_project=project) # Adjust dates to reverse the sorted order of the nominations. noms[1].date -= timedelta(days=3) feed = feeds.nomination_feed() items = feed.items(project) assert items[0] == noms[1] assert items[1] == noms[0]
def test_items_returns_only_project_nominations(self): project = factories.ProjectFactory() noms = factories.NominatedURLFactory.create_batch(3, url_project=project) factories.URLFactory.create_batch(3, url_project=project) factories.NominatedURLFactory.create_batch(3) feed = feeds.nomination_feed() items = feed.items(project) assert len(items) == 3 for nom in items: assert nom in noms
def test_item_description(self, rf): project = factories.ProjectFactory() nom = factories.SURTFactory(url_project=project, entity='www.example.com') factories.URLFactory( url_project=project, entity=nom.entity, attribute='Description', value='Home Page' ) request = rf.get('/') feed = feeds.nomination_feed() feed.get_object(request, project.project_slug) item_description = feed.item_description(nom) assert item_description == 'www.example.com - Home Page'
url(r"^$", project_listing, name='project_listing'), url(r"^robots.txt$", robot_ban, name='robot_ban'), url(r"^about/$", nomination_about, name='nomination_about'), url(r"^help/$", nomination_help, name='nomination_help'), #url(r"^about/$", include('django.contrib.flatpages.urls'), name='nomination_about'), #url(r"^help/$", include('django.contrib.flatpages.urls'), name='nomination_help'), url(r"([^/]+)/lookup/$", url_lookup, name='url_lookup'), url(r"([^/]+)/search.json$", search_json, name='search_json'), url(r"([^/]+)/browse/([^/]+)/browse.json$", browse_json, name='browse_json'), url(r"([^/]+)/reports/projectdump/$", project_dump, name='project_dump'), url(r"([^/]+)/reports/urls/score/$", url_score_report, name='url_score_report'), url(r"([^/]+)/reports/urls/nomination/$", url_nomination_report, name='url_nomination_report'), url(r"([^/]+)/reports/urls/date/$", url_date_report, name='url_date_report'), url(r"([^/]+)/reports/urls/$", url_report, name='url_report'), url(r"([^/]+)/reports/surts/$", surt_report, name='surt_report'), url(r"([^/]+)/reports/metadata/(nominator|institution)/$", nominator_report, name='nominator_report'), url(r"([^/]+)/reports/metadata/(nominator|institution)/([^/]+)/$", nominator_url_report, name='nominator_url_report'), url(r"([^/]+)/reports/metadata/([^/]+)/$", field_report, name='field_report'), #commented out line below for line under that in case user input value contains '/' #url(r"([^/]+)/reports/metadata/([^/]+)/([^/]+)/$", value_report, name='value_report'), url(r"([^/]+)/reports/metadata/([^/]+)/((?:.|\s)+)/$", value_report, name='value_report'), url(r"([^/]+)/reports/$", reports_view, name='reports_view'), url(r"^(?P<slug>[^/]+)/url/(?P<url_entity>[\w\W]+)/$", url_listing, name='url_listing'), url(r"^(?P<slug>[^/]+)/surt/(?P<surt>[\w\W]+)/$", url_surt, name='url_surt'), url(r"([^/]+)/add/$", url_add, name='url_add'), url(r"([^/]+)/about/$", project_about, name='project_about'), url(r"([^/]+)/feed/nominations/$", nomination_feed(), name='nomination_feed'), url(r"([^/]+)/feed/urls/$", url_feed(), name='url_feed'), url(r"([^/]+)/$", project_urls, name='project_urls'), )
def test_title(self): project = factories.ProjectFactory(project_name='Test Project') feed = feeds.nomination_feed() title = feed.title(project) assert title == 'Most Recent Nominations for Test Project'
def test_get_object_raises_404(self, rf): request = rf.get('/') feed = feeds.nomination_feed() with pytest.raises(Http404): feed.get_object(request, '')