Ejemplo n.º 1
0
 def setUp(self):
     feed = Feed(
         title='test feed',
         url='https://blog.example.com/feed.xml',
         status=FeedStatus.READY,
         dt_updated=timezone.now(),
     )
     feed.save()
Ejemplo n.º 2
0
 def setUp(self):
     feed = Feed(
         title='测试1',
         url='https://blog.example.com/feed1.xml',
         status=FeedStatus.READY,
         dt_updated=timezone.now(),
     )
     feed.save()
     tester = User.objects.create_superuser('tester',
                                            email=None,
                                            password='******')
     self._tester = tester
Ejemplo n.º 3
0
def _create_test_feed(url):
    feed = Feed.get_first_by_url(url)
    if not feed:
        now = timezone.now()
        feed = Feed(url=url,
                    status=FeedStatus.DISCARD,
                    reverse_url=reverse_url(url),
                    title='蚁阅测试订阅',
                    dt_updated=now,
                    dt_checked=now,
                    dt_synced=now)
        feed.save()
    return feed
Ejemplo n.º 4
0
    def setUp(self):
        print('setUp')
        storys = []
        updated_storys = []
        now = timezone.datetime(2020, 6, 1, 12, 12, 12, tzinfo=timezone.utc)
        for i in range(200):
            dt = now + timezone.timedelta(minutes=i)
            content = f'test story content {i}' * (i % 5)
            content_hash_base64 = compute_hash_base64(content)
            summary = content[:30]
            story = {
                'unique_id': f'blog.example.com/{i}',
                'title': f'test story {i}',
                'content_hash_base64': content_hash_base64,
                'author': 'tester',
                'link': f'https://blog.example.com/{i}.html',
                'dt_published': dt,
                'dt_updated': dt,
                'summary': summary,
                'content': content,
            }
            storys.append(validate_story(story))
            updated_story = dict(story)
            updated_content = f'test story content updated {i}' * (i % 5 + 1)
            updated_story.update(
                content=updated_content,
                content_hash_base64=compute_hash_base64(updated_content),
            )
            updated_storys.append(validate_story(updated_story))
        self.storys = storys
        self.updated_storys = updated_storys

        feed = Feed(
            title='test feed',
            url='https://blog.example.com/feed.xml',
            status=FeedStatus.READY,
            dt_updated=timezone.now(),
        )
        feed.save()
        self.feed_id = feed.id
Ejemplo n.º 5
0
 def _import_feeds(self, imports: list):
     result = UnionFeed.create_by_imports(user_id=self._tester.id,
                                          imports=imports)
     for creation in result.feed_creations:
         creation: FeedCreation
         feed = Feed(
             title=creation.title,
             url=creation.url,
             status=FeedStatus.READY,
             dt_updated=timezone.now(),
         )
         feed.save()
         user_feed = UserFeed(
             user=self._tester,
             feed=feed,
             title=creation.title,
             group=creation.group,
             dt_updated=timezone.now(),
         )
         user_feed.save()
         FeedUrlMap(source=creation.url, target=feed.url).save()
         FeedUrlMap(source=creation.url + '.c', target=feed.url).save()
     return result