forked from gergely/calendar-social
Add test for following a user through the web UI
This commit is contained in:
@@ -18,9 +18,9 @@
|
||||
"""
|
||||
|
||||
import calsocial
|
||||
from calsocial.models import db, Notification, NotificationAction, Profile, User
|
||||
from calsocial.models import db, Notification, NotificationAction, Profile, User, UserFollow
|
||||
|
||||
from helpers import database
|
||||
from helpers import client, database, login
|
||||
|
||||
|
||||
def test_profile_follow(database):
|
||||
@@ -53,3 +53,32 @@ def test_profile_follow(database):
|
||||
|
||||
assert follower in followed.follower_list
|
||||
assert followed in follower.followed_list
|
||||
|
||||
|
||||
def test_follow_ui(client):
|
||||
"""Test following on the web interface
|
||||
"""
|
||||
|
||||
with calsocial.app.app_context():
|
||||
follower_user = User(username='follower',
|
||||
email='follower@example.com',
|
||||
password='passworder',
|
||||
active=True)
|
||||
followed_user = User(username='followed', email='followed@example.com')
|
||||
follower = Profile(display_name='Follower', user=follower_user)
|
||||
followed = Profile(display_name='Followed', user=followed_user)
|
||||
db.session.add_all([follower, followed])
|
||||
db.session.commit()
|
||||
|
||||
login(client, 'follower', 'passworder')
|
||||
|
||||
page = client.get('/profile/@followed/follow')
|
||||
assert page.status_code == 302
|
||||
assert page.location == 'http://localhost/profile/%40followed'
|
||||
|
||||
with calsocial.app.app_context():
|
||||
db.session.add_all([follower, followed])
|
||||
follow = UserFollow.query.one()
|
||||
assert follow.follower == follower
|
||||
assert follow.followed == followed
|
||||
assert follow.accepted_at is not None
|
||||
|
Reference in New Issue
Block a user