-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathtest_share_event.py
55 lines (46 loc) · 2.02 KB
/
test_share_event.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from app.routers.invitation import get_all_invitations
from app.routers.share import (accept, send_email_invitation,
send_in_app_invitation, share, sort_emails)
class TestShareEvent:
def test_share_success(self, user, event, session):
participants = [user.email]
share(event, participants, session)
invitations = get_all_invitations(db=session, recipient_id=user.id)
assert invitations != []
def test_share_failure(self, event, session):
participants = [event.owner.email]
share(event, participants, session)
invitations = get_all_invitations(
db=session, recipient_id=event.owner.id)
assert invitations == []
def test_sort_emails(self, user, session):
# the user is being imported
# so he will be created
data = [
'[email protected]', # registered user
'[email protected]', # unregistered user
]
sorted_data = sort_emails(data, session=session)
assert sorted_data == {
'registered': ['[email protected]'],
'unregistered': ['[email protected]']
}
def test_send_in_app_invitation_success(
self, user, sender, event, session
):
assert send_in_app_invitation([user.email], event, session=session)
invitation = get_all_invitations(db=session, recipient=user)[0]
assert invitation.event.owner == sender
assert invitation.recipient == user
session.delete(invitation)
def test_send_in_app_invitation_failure(
self, user, sender, event, session):
assert (send_in_app_invitation(
[sender.email], event, session=session) is False)
def test_send_email_invitation(self, user, event):
send_email_invitation([user.email], event)
# TODO add email tests
assert True
def test_accept(self, invitation, session):
accept(invitation, session=session)
assert invitation.status == 'accepted'