Ejemplo n.º 1
0
def llanguage(msg):
    chat = msg.chat
    base.create_user(msg.chat.id, msg.text)
    markup = telebot.types.ReplyKeyboardMarkup(True, True)
    markup.row("ok")
    str = bot.send_message(msg.chat.id,
                           base.get_text(msg.chat.id, "confirm"),
                           reply_markup=markup)
    bot.register_next_step_handler(str, welcome)
Ejemplo n.º 2
0
def register_new_user(req: Request):
    try:
        base.create_user(req.obj["username"], req.obj["firstName"],
                         req.obj["lastName"], req.obj["password"],
                         req.obj["email"])
        response = Response(201)
    except KeyError:
        response = error_response(406, "username", "firstName", "lastName",
                                  "password", "email")
    except (base.utils.UserAlreadyExists, base.utils.EmailAlreadyLinked) as e:
        response = Response(406, str(e))
    except Exception as e:
        response = Response(500, body=str(e))
    return response
Ejemplo n.º 3
0
def test_workshop_create(base_url, browser, outbox):
    """
    """
    f.create_usertype(slug='tutor', display_name='tutor')
    poc_type = f.create_usertype(slug='poc', display_name='poc')
    state = f.create_state()
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)
    user.save()
    location = f.create_locaiton(name='location1')
    user.profile.location = location
    user.profile.usertype.clear()
    user.profile.usertype.add(poc_type)
    user.profile.interested_states.add(state)

    user.profile.save()

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)

    # validate if user belongs to organisation
    url = base_url + '/workshop/create/'
    browser.visit(url)
    assert browser.is_text_present("create organisaiton.")
    # Create org
    org = f.create_organisation(location=location)
    org.user.add(user)
    user.profile.interested_locations.add(org.location)
#     user.profile.location = org.location
#     user.profile.save()
    org.save()
    section1 = f.create_workshop_section(name='section1')

    # invalid form
    url = base_url + '/workshop/create/'
    browser.visit(url)
    browser.fill('no_of_participants', 10)
    browser.fill('expected_date', '11/12/2018')
    browser.find_by_css('[type=submit]')[0].click()
    assert browser.is_text_present('This field is required.')
    # valid form
    url = base_url + '/workshop/create/'
    base.workshop_create(browser, url, org, section1)
Ejemplo n.º 4
0
def test_workshop_create(base_url, browser, outbox):
    """
    """
    f.create_usertype(slug='tutor', display_name='tutor')
    poc_type = f.create_usertype(slug='poc', display_name='poc')
    state = f.create_state()
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)
    user.save()
    location = f.create_locaiton(name='location1')
    user.profile.location = location
    user.profile.usertype.clear()
    user.profile.usertype.add(poc_type)
    user.profile.interested_states.add(state)

    user.profile.save()

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)

    # validate if user belongs to organisation
    url = base_url + '/workshop/create/'
    browser.visit(url)
    assert browser.is_text_present("create organisaiton.")
    # Create org
    org = f.create_organisation(location=location)
    org.user.add(user)
    user.profile.interested_locations.add(org.location)
    #     user.profile.location = org.location
    #     user.profile.save()
    org.save()
    section1 = f.create_workshop_section(name='section1')

    # invalid form
    url = base_url + '/workshop/create/'
    browser.visit(url)
    browser.fill('no_of_participants', 10)
    browser.fill('expected_date', '11/12/2018')
    browser.find_by_css('[type=submit]')[0].click()
    assert browser.is_text_present('This field is required.')
    # valid form
    url = base_url + '/workshop/create/'
    base.workshop_create(browser, url, org, section1)
Ejemplo n.º 5
0
def test_workshop_create(base_url, browser, outbox):
    """
    """
    f.create_usertype(slug="tutor", display_name="tutor")
    user = base.create_user(password)
    url = base_url + "/workshop/"
    base.login_and_confirm(browser, url, outbox, user, password)
    user.save()
    location = f.create_locaiton(name="location1")
    user.profile.location = location
    user.profile.save()

    url = base_url + "/workshop/"
    base.login(browser, url, user, password)

    # validate if user belongs to organisation
    url = base_url + "/workshop/create/"
    browser.visit(url)
    assert browser.is_text_present("create organisaiton.")
    # Create org
    org = f.create_organisation(location=location)
    org.user.add(user)
    user.profile.interested_locations.add(org.location)
    #     user.profile.location = org.location
    #     user.profile.save()
    org.save()
    section1 = f.create_workshop_section(name="section1")

    # invalid form
    url = base_url + "/workshop/create/"
    browser.visit(url)
    browser.fill("no_of_participants", 10)
    browser.fill("expected_date", "11/12/2018")
    browser.find_by_css("[type=submit]")[0].click()
    assert browser.is_text_present("This field is required.")
    # valid form
    url = base_url + "/workshop/create/"
    base.workshop_create(browser, url, org, section1)
Ejemplo n.º 6
0
def test_workshop_list(base_url, browser, outbox):
    """
    Following testcases will be checked:
    - Check workshop listing for user with usertype poc
    - Check workshop listing for user with usertype tutor
    - Check workshop listing for user with usertype lead
    - Check workshop listing for user with no usertype
    """

    # Create usertypes
    # poc_type = f.create_usertype(slug='poc', display_name='poc')
    # tutor_type = f.create_usertype(slug='tutor', display_name='tutor')
    regional_lead_type = f.create_usertype(
        slug='lead', display_name='regional lead')

    # Testcase with usertyep poc
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)
    # user.profile.usertype.add(poc_type)
    # user.save()

    # Create org
    org = f.create_organisation()
    org.user.add(user)
    user.profile.interested_locations.add(org.location)
    user.profile.location = org.location
    user.profile.save()
    org.save()

    # Create workshop
    workshop = f.create_workshop(requester=org)
    workshop.expected_date = datetime.now() + timedelta(days=20)
    workshop.status = WorkshopStatus.REQUESTED
    workshop.location = org.location
    workshop.save()

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)
    data_check = browser.find_by_text(org.name)
    assert data_check

    # Testcase for usertype tutor
    browser.visit(base_url + "/accounts/logout")
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)
    # user.profile.usertype.add(tutor_type)
    # user.save()

    # url = base_url + '/workshop/'
    # base.login(browser, url, user, password)
    # # User not associate with workshop
    # data_check = browser.find_by_text(org.name)
    # assert [] == data_check

    # User associated with workshop
    workshop.presenter.add(user)
    browser.visit(url)
    # data_check = browser.find_by_text(org.name)
    # assert data_check

    # Testcase for lead
    browser.visit(base_url + "/accounts/logout")
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)

    user.profile.usertype.add(regional_lead_type)
    user.save()
    lead = RegionalLead.objects.create(location=org.location)
    lead.leads.add(user)

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)
    # data_check = browser.find_by_text(org.name)
    # assert data_check

    # Testcase for user with no usertype
    browser.visit(base_url + "/accounts/logout")
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)
Ejemplo n.º 7
0
def test_workshop_list(base_url, browser, outbox):
    """
    Following testcases will be checked:
    - Check workshop listing for user with usertype poc
    - Check workshop listing for user with usertype tutor
    - Check workshop listing for user with usertype lead
    - Check workshop listing for user with no usertype
    """

    # Create usertypes
    poc_type = f.create_usertype(slug='poc', display_name='poc')
    tutor_type = f.create_usertype(slug='tutor', display_name='tutor')
    regional_lead_type = f.create_usertype(slug='lead', display_name='regional lead')

    # Testcase with usertyep poc
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)
    user.profile.usertype.add(poc_type)
    user.save()

    # Create org
    org = f.create_organisation()
    org.user.add(user)
    user.profile.interested_locations.add(org.location)
    org.save()

    # Create workshop
    workshop = f.create_workshop(requester=org)
    workshop.expected_date = datetime.now() + timedelta(days=20)
    workshop.status = WorkshopStatus.REQUESTED
    workshop.location = org.location
    workshop.save()

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)
    data_check = browser.find_by_text(org.name)
    assert data_check

    # Testcase for usertype tutor
    browser.visit(base_url + "/accounts/logout")
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)
    user.profile.usertype.add(tutor_type)
    user.save()

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)
    # User not associate with workshop
    data_check = browser.find_by_text(org.name)
    assert [] == data_check

    # User associated with workshop
    workshop.presenter.add(user)
    browser.visit(url)
    data_check = browser.find_by_text(org.name)
    assert data_check

    # Testcase for lead
    browser.visit(base_url + "/accounts/logout")
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)

    user.profile.usertype.add(regional_lead_type)
    user.save()
    lead = RegionalLead.objects.create(location=org.location)
    lead.leads.add(user)

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)
    data_check = browser.find_by_text(org.name)
    assert data_check

    # Testcase for user with no usertype
    browser.visit(base_url + "/accounts/logout")
    user = base.create_user(password)
    url = base_url + '/workshop/'
    base.login_and_confirm(browser, url, outbox, user, password)

    url = base_url + '/workshop/'
    base.login(browser, url, user, password)
    data_check = browser.find_by_text(org.name)
    assert [] == data_check