add some test

This commit is contained in:
Your Name 2023-07-08 17:28:05 -04:00 committed by Henri Dickson
parent 386f6a2a40
commit 32d1f062bc
4 changed files with 29 additions and 5 deletions

View file

@ -52,3 +52,15 @@ class SocialTest(TestCase):
self.assertEqual(len(timeline), 3)
timeline2 = self.bob.activity_manager.get_timeline()
self.assertEqual(len(timeline2), 2)
# remote unfollow
self.bob.mastodon_following = []
self.alice.mastodon_follower = []
self.bob.merge_relationships()
timeline = self.bob.activity_manager.get_timeline()
self.assertEqual(len(timeline), 0)
# local follow
self.bob.follow(self.alice)
timeline = self.bob.activity_manager.get_timeline()
self.assertEqual(len(timeline), 2)

View file

@ -124,7 +124,7 @@
{% if user.mastodon_last_refresh %}上次更新时间 {{ user.mastodon_last_refresh }}{% endif %}
</small>
<div>
为了正确高效的展示短评和评论,{{ site_name }}会缓存你在联邦宇宙的关注、屏蔽和静音列表。如果你刚刚更新过帐户的上锁状态、增减过关注、静音或屏蔽,希望立即生效,可以点击这里立刻更新;这类信息也会每天自动同步。
为了正确高效的展示短评和评论,{{ site_name }}会缓存你在联邦宇宙的关注、屏蔽和隐藏列表。如果你刚刚更新过帐户的上锁状态、增减过关注、隐藏或屏蔽,希望立即生效,可以点击这里立刻更新;这类信息也会每天自动同步。
</div>
</form>
</details>

View file

@ -15,7 +15,7 @@
<a id="download_{{ id }}" title="导出列表" download="neodb_{{ id }}.csv"><i class="fa-solid fa-download"></i></a>
</span>
</span>
此处只列出你在{{ site_name }}{{ name }},联邦宇宙{{ name }}列表可在你所属实例查询管理。
此处仅列出并可导出你在{{ site_name }}的{{ name }},联邦宇宙{{ name }}列表可在你所属实例查询管理。
</p>
<script>
let csv = "data:text/csv;charset=utf-8,Account address,Show boosts,Notify on new posts,Languages\n"

View file

@ -10,7 +10,7 @@ class UserTest(TestCase):
self.bob = User.objects.create(mastodon_site="KKCity", mastodon_username="Bob")
def test_local_follow(self):
self.alice.follow(self.bob)
self.assertTrue(self.alice.follow(self.bob))
self.assertTrue(
Follow.objects.filter(owner=self.alice, target=self.bob).exists()
)
@ -19,13 +19,13 @@ class UserTest(TestCase):
self.assertTrue(self.alice.is_following(self.bob))
self.assertTrue(self.bob.is_followed_by(self.alice))
self.alice.follow(self.bob)
self.assertFalse(self.alice.follow(self.bob))
self.assertEqual(
Follow.objects.filter(owner=self.alice, target=self.bob).count(), 1
)
self.assertEqual(self.alice.following, [self.bob.pk])
self.alice.unfollow(self.bob)
self.assertTrue(self.alice.unfollow(self.bob))
self.assertFalse(
Follow.objects.filter(owner=self.alice, target=self.bob).exists()
)
@ -33,6 +33,18 @@ class UserTest(TestCase):
self.assertFalse(self.bob.is_followed_by(self.alice))
self.assertEqual(self.alice.following, [])
def test_locked(self):
self.bob.mastodon_locked = True
self.bob.save()
self.assertFalse(self.alice.follow(self.bob))
self.bob.mastodon_locked = False
self.bob.save()
self.assertTrue(self.alice.follow(self.bob))
self.assertTrue(self.alice.is_following(self.bob))
self.bob.mastodon_locked = True
self.bob.save()
self.assertFalse(self.alice.is_following(self.bob))
def test_external_follow(self):
self.alice.mastodon_following.append(self.bob.mastodon_acct)
self.alice.merge_relationships()