Completed
Push — master ( 2b3bff...10952a )
by Vijay
02:16 queued 01:05
created

test_workshop_create()   B

Complexity

Conditions 3

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
dl 0
loc 37
rs 8.8571
c 1
b 0
f 0
1
import base
2
from tests import factories as f
3
4
outbox_len = 0
5
password = '123123'
6
7
8
def test_workshop_create(base_url, browser, outbox):
9
    """
10
    """
11
    user = base.create_user(password)
12
    url = base_url + '/workshop/'
13
    base.login_and_confirm(browser, url, outbox, user, password)
14
    user.save()
15
    location = f.create_locaiton(name='location1')
16
    user.profile.location = location
17
    user.profile.save()
18
19
    url = base_url + '/workshop/'
20
    base.login(browser, url, user, password)
21
22
    # validate if user belongs to organisation
23
    url = base_url + '/workshop/create/'
24
    browser.visit(url)
25
    assert browser.is_text_present("create organisaiton.")
26
    # Create org
27
    org = f.create_organisation(location=location)
28
    org.user.add(user)
29
    user.profile.interested_locations.add(org.location)
30
#     user.profile.location = org.location
31
#     user.profile.save()
32
    org.save()
33
    section1 = f.create_workshop_section(name='section1')
34
35
    # invalid form
36
    url = base_url + '/workshop/create/'
37
    browser.visit(url)
38
    browser.fill('no_of_participants', 10)
39
    browser.fill('expected_date', '11/12/2018')
40
    browser.find_by_css('[type=submit]')[0].click()
41
    assert browser.is_text_present('This field is required.')
42
    # valid form
43
    url = base_url + '/workshop/create/'
44
    base.workshop_create(browser, url, org, section1)
45