def test_latest_newsitem(self): """ Pass the most-recently-created visible NewsItem to the template context. """ old_newsitem = NewsItemFactory.create(visible=True) old_newsitem.created = aware_datetime(2014, 1, 1) old_newsitem.save() non_visible_newsitem = NewsItemFactory.create(visible=False) non_visible_newsitem.created = aware_datetime(2014, 1, 5) non_visible_newsitem.save() visible_newsitem = NewsItemFactory.create(visible=True) visible_newsitem.created = aware_datetime(2014, 1, 4) visible_newsitem.save() request = Mock() with patch('affiliates.base.views.render') as render: views.dashboard(request) render.assert_called_with(request, 'base/dashboard.html', { 'newsitem': visible_newsitem, 'milestones': ANY, })
def test_latest_newsitem(self): """ Pass the most-recently-created visible NewsItem to the template context. """ old_newsitem = NewsItemFactory.create(visible=True) old_newsitem.created = aware_datetime(2014, 1, 1) old_newsitem.save() non_visible_newsitem = NewsItemFactory.create(visible=False) non_visible_newsitem.created = aware_datetime(2014, 1, 5) non_visible_newsitem.save() visible_newsitem = NewsItemFactory.create(visible=True) visible_newsitem.created = aware_datetime(2014, 1, 4) visible_newsitem.save() request = Mock(user=UserFactory.create()) with patch('affiliates.base.views.render') as render: views.dashboard(request) render.assert_called_with(request, 'base/dashboard.html', { 'newsitem': visible_newsitem, 'milestones': ANY, 'links': ANY, })
def test_no_available_newsitem(self): """ If there are no visible NewsItems, pass None to the template context. """ NewsItemFactory.create_batch(3, visible=False) request = Mock(user=UserFactory.create()) with patch('affiliates.base.views.render') as render: views.dashboard(request) render.assert_called_with(request, 'base/dashboard.html', { 'links': ANY, })
def test_no_available_newsitem(self): """ If there are no visible NewsItems, pass None to the template context. """ NewsItemFactory.create_batch(3, visible=False) request = Mock() with patch('affiliates.base.views.render') as render: views.dashboard(request) render.assert_called_with(request, 'base/dashboard.html', { 'newsitem': None, 'milestones': ANY, })