def test_run(self): self.assertEqual(len(AllFieldsTestCase.TRIALS), len(fields._field_configs)) for key, generator in AllFieldsTestCase.TRIALS.items(): with self.subTest(key=key): db_objs = generator() fields_dict = fields._field_configs[key] for db_obj in db_objs: for field_config in fields_dict.values(): context = Context() context.request = AllFieldsTestCase.MockRequest() field_config.accessor(context, db_obj)
def test_run(self): self.assertEqual(len(AllSearchesTestCase.TRIALS), len(searches._search_fns)) for key, trial_dict in AllSearchesTestCase.TRIALS.items(): with self.subTest(key=key): search_fns_dict = searches._search_fns[key] trial_searches = trial_dict['searches'] self.assertEqual(len(trial_searches), len(search_fns_dict)) queryset = trial_dict['get_queryset']() for field, test_values in trial_searches.items(): for test_value in test_values: with self.subTest(field=field, test_value=test_value): context = Context() context.request = AllSearchesTestCase.MockRequest() q = search_fns_dict[field](context, test_value) result = list(queryset.filter(q)) self.assertIsNotNone(result)
def test_feedentry_isRead(self): context = Context() user = models.User.objects.create( email='*****@*****.**') class MockRequest: def __init__(self): self.user = user context.request = MockRequest() feed = models.Feed.objects.create( feed_url='http://example.com/rss.xml', title='Sample Feed', home_url='http://example.com', published_at=datetime.datetime.utcnow(), updated_at=None, db_updated_at=None) feed_entry1 = models.FeedEntry.objects.create( feed=feed, url='http://example.com/entry1.html', content='<b>Some HTML Content</b>', author_name='John Doe') feed_entry2 = models.FeedEntry.objects.create( feed=feed, url='http://example.com/entry2.html', content='<b>Some HTML Content</b>', author_name='John Doe') models.ReadFeedEntryUserMapping.objects.create( feed_entry=feed_entry2, user=user) self.assertIsNone(fields._feedentry_readAt(context, feed_entry1)) self.assertIsNotNone(fields._feedentry_readAt(context, feed_entry2))