Completed
Push — master ( 31afa4...8466ee )
by Vijay
10s
created

test_report_home_page()   B

Complexity

Conditions 4

Size

Total Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 46
rs 8.6315
cc 4
1
import re
2
from .. import factories as f
3
from wye.base.constants import WorkshopStatus
4
5
6
def test_report_home_page(base_url, browser, outbox):
7
    f.create_usertype(slug='tutor', display_name='tutor')
8
    user = f.create_user()
9
    user.set_password('123123')
10
    user.save()
11
    url = base_url + '/accounts/login/'
12
    browser.visit(url)
13
    browser.fill('login', user.email)
14
    browser.fill('password', '123123')
15
    browser.find_by_css('[type=submit]')[0].click()
16
    assert len(outbox) == 1
17
    mail = outbox[0]
18
    confirm_link = re.findall(r'http.*/accounts/.*/', mail.body)
19
    assert confirm_link
20
    browser.visit(confirm_link[0])
21
    assert browser.title, "Confirm E-mail Address"
22
    browser.find_by_css('[type=submit]')[0].click()
23
24
    location1 = f.create_locaiton(name='location1')
25
    poc_type = f.create_usertype(slug='poc', display_name='poc')
26
    user.profile.usertype.clear()
27
    user.profile.usertype.add(poc_type)
28
    user.profile.location = location1
29
    user.profile.save()
30
    user.save()
31
32
    org = f.create_organisation()
33
    org.user.add(user)
34
    user.profile.interested_locations.add(org.location)
35
    user.profile.location = org.location
36
    user.profile.save()
37
    org.save()
38
39
    workshop = f.create_workshop(requester=org)
40
    workshop.status = WorkshopStatus.COMPLETED
41
    workshop.save()
42
43
    url = base_url + '/reports/'
44
    browser.fill('login', user.email)
45
    browser.fill('password', '123123')
46
    browser.find_by_css('[type=submit]')[0].click()
47
    browser.visit(url)
48
49
    user.is_staff = True
50
    user.save()
51
    browser.visit(url)
52
53
54
def test_report_page(base_url, browser, outbox):
55
    f.create_usertype(slug='tutor', display_name='tutor')
56
    user = f.create_user()
57
    user.set_password('123123')
58
    user.save()
59
    url = base_url + '/accounts/login/'
60
    browser.visit(url)
61
    browser.fill('login', user.email)
62
    browser.fill('password', '123123')
63
    browser.find_by_css('[type=submit]')[0].click()
64
    assert len(outbox) == 1
65
    mail = outbox[0]
66
    confirm_link = re.findall(r'http.*/accounts/.*/', mail.body)
67
    assert confirm_link
68
    browser.visit(confirm_link[0])
69
    assert browser.title, "Confirm E-mail Address"
70
    browser.find_by_css('[type=submit]')[0].click()
71
72
    location1 = f.create_locaiton(name='location1')
73
    poc_type = f.create_usertype(slug='poc', display_name='poc')
74
    user.profile.usertype.clear()
75
    user.profile.usertype.add(poc_type)
76
    user.profile.location = location1
77
    user.profile.save()
78
    user.save()
79
80
    url = base_url + '/reports/'
81
    browser.fill('login', user.email)
82
    browser.fill('password', '123123')
83
    browser.find_by_css('[type=submit]')[0].click()
84
    browser.visit(url)
85
86
    user.is_staff = True
87
    user.save()
88
    browser.visit(url)
89
    browser.find_by_css('[type=submit]')[0].click()
90