kopia lustrzana https://gitlab.com/marnanel/chapeau
LocalPerson gains has_liked(). Tests updated.
rodzic
baabe28692
commit
0d5b665434
|
@ -119,6 +119,18 @@ class Person(PolymorphicModel):
|
|||
def emojis(self):
|
||||
return [] # FIXME
|
||||
|
||||
def has_liked(self, status):
|
||||
from kepi.trilby_api.models.like import Like
|
||||
|
||||
try:
|
||||
Like.objects.get(
|
||||
liker = self,
|
||||
liked = status,
|
||||
)
|
||||
return True
|
||||
except Like.DoesNotExist:
|
||||
return False
|
||||
|
||||
########################################
|
||||
|
||||
class RemotePerson(Person):
|
||||
|
|
|
@ -87,3 +87,27 @@ class TestPerson(TrilbyTestCase):
|
|||
'https://testserver/users/bob',
|
||||
],
|
||||
)
|
||||
|
||||
def test_has_liked(self):
|
||||
alice = create_local_person(name='alice',
|
||||
auto_follow=False)
|
||||
bob = create_local_person(name='bob',
|
||||
auto_follow=False)
|
||||
|
||||
status1 = create_local_status(
|
||||
content = 'A crowd flowed over London Bridge, so many',
|
||||
posted_by = bob,
|
||||
)
|
||||
status2 = create_local_status(
|
||||
content = 'I had not thought that death had undone so many',
|
||||
posted_by = bob,
|
||||
)
|
||||
|
||||
Like(liker=alice, liked=status1).save()
|
||||
|
||||
self.assertTrue(
|
||||
alice.has_liked(status1),
|
||||
)
|
||||
self.assertFalse(
|
||||
alice.has_liked(status2),
|
||||
)
|
||||
|
|
Ładowanie…
Reference in New Issue