Commit 86afe727 by Jay Zoldak

Refactor user factory usage for lettuce tests. Fix merge conflict.

parent 1c209789
...@@ -50,31 +50,31 @@ def i_press_the_category_delete_icon(step, category): ...@@ -50,31 +50,31 @@ def i_press_the_category_delete_icon(step, category):
@step('I have opened a new course in Studio$') @step('I have opened a new course in Studio$')
def i_have_opened_a_new_course(step): def i_have_opened_a_new_course(step):
open_new_course()
####### HELPER FUNCTIONS ##############
def open_new_course():
world.clear_courses() world.clear_courses()
log_into_studio() log_into_studio()
create_a_course() create_a_course()
####### HELPER FUNCTIONS ##############
def create_studio_user( def create_studio_user(
uname='robot', uname='robot',
email='robot+studio@edx.org', email='robot+studio@edx.org',
password='test', password='test',
is_staff=False): is_staff=False):
studio_user = world.UserFactory.build( studio_user = world.UserFactory(
username=uname, username=uname,
email=email, email=email,
password=password, password=password,
is_staff=is_staff) is_staff=is_staff)
studio_user.set_password(password)
studio_user.save()
registration = world.RegistrationFactory(user=studio_user) registration = world.RegistrationFactory(user=studio_user)
registration.register(studio_user) registration.register(studio_user)
registration.activate() registration.activate()
user_profile = world.UserProfileFactory(user=studio_user)
def fill_in_course_info( def fill_in_course_info(
name='Robot Super Course', name='Robot Super Course',
...@@ -153,4 +153,4 @@ def set_date_and_time(date_css, desired_date, time_css, desired_time): ...@@ -153,4 +153,4 @@ def set_date_and_time(date_css, desired_date, time_css, desired_time):
world.css_fill(time_css, desired_time) world.css_fill(time_css, desired_time)
e = world.css_find(time_css).first e = world.css_find(time_css).first
e._element.send_keys(Keys.TAB) e._element.send_keys(Keys.TAB)
time.sleep(float(1)) time.sleep(float(1))
...@@ -14,8 +14,6 @@ SHOW_ANSWER = "Show Answer" ...@@ -14,8 +14,6 @@ SHOW_ANSWER = "Show Answer"
############### ACTIONS #################### ############### ACTIONS ####################
@step('I have created a Blank Common Problem$') @step('I have created a Blank Common Problem$')
def i_created_blank_common_problem(step): def i_created_blank_common_problem(step):
world.create_component_instance(step, '.large-problem-icon', 'i4x://edx/templates/problem/Blank_Common_Problem',
'.xmodule_CapaModule')
world.create_component_instance( world.create_component_instance(
step, step,
'.large-problem-icon', '.large-problem-icon',
...@@ -96,7 +94,6 @@ def i_can_revert_to_default_for_randomization(step): ...@@ -96,7 +94,6 @@ def i_can_revert_to_default_for_randomization(step):
world.verify_setting_entry(world.get_setting_entry(RANDOMIZATION), RANDOMIZATION, "Always", False) world.verify_setting_entry(world.get_setting_entry(RANDOMIZATION), RANDOMIZATION, "Always", False)
@step('I can set the weight to 3.5') @step('I can set the weight to 3.5')
def i_can_set_weight_to_3_5(step): def i_can_set_weight_to_3_5(step):
world.get_setting_entry(PROBLEM_WEIGHT).find_by_css('.setting-input')[0].fill('3.5') world.get_setting_entry(PROBLEM_WEIGHT).find_by_css('.setting-input')[0].fill('3.5')
...@@ -104,19 +101,18 @@ def i_can_set_weight_to_3_5(step): ...@@ -104,19 +101,18 @@ def i_can_set_weight_to_3_5(step):
@step('my change to weight is persisted') @step('my change to weight is persisted')
def my_change_to_randomization_is_persisted(step): def my_change_to_weight_is_persisted(step):
world.save_component_and_reopen(step) world.save_component_and_reopen(step)
verify_modified_weight() verify_modified_weight()
@step('I can revert to the default value of unset for weight') @step('I can revert to the default value of unset for weight')
def i_can_revert_to_default_for_randomization(step): def i_can_revert_to_default_for_unset_weight(step):
world.revert_setting_entry(PROBLEM_WEIGHT) world.revert_setting_entry(PROBLEM_WEIGHT)
world.save_component_and_reopen(step) world.save_component_and_reopen(step)
world.verify_setting_entry(world.get_setting_entry(PROBLEM_WEIGHT), PROBLEM_WEIGHT, "", False) world.verify_setting_entry(world.get_setting_entry(PROBLEM_WEIGHT), PROBLEM_WEIGHT, "", False)
@step('if I set the weight to abc, it remains unset') @step('if I set the weight to abc, it remains unset')
def set_the_weight_to_abc(step): def set_the_weight_to_abc(step):
world.get_setting_entry(PROBLEM_WEIGHT).find_by_css('.setting-input')[0].fill('abc') world.get_setting_entry(PROBLEM_WEIGHT).find_by_css('.setting-input')[0].fill('abc')
...@@ -127,16 +123,14 @@ def set_the_weight_to_abc(step): ...@@ -127,16 +123,14 @@ def set_the_weight_to_abc(step):
world.verify_setting_entry(world.get_setting_entry(PROBLEM_WEIGHT), PROBLEM_WEIGHT, "", False) world.verify_setting_entry(world.get_setting_entry(PROBLEM_WEIGHT), PROBLEM_WEIGHT, "", False)
@step('if I set the max attempts to 2.34, the max attempts are persisted as 234') @step('if I set the max attempts to 2.34, the max attempts are persisted as 234')
def set_the_weight_to_abc(step): def set_the_max_attempts_234(step):
world.get_setting_entry(MAXIMUM_ATTEMPTS).find_by_css('.setting-input')[0].fill('2.34') world.get_setting_entry(MAXIMUM_ATTEMPTS).find_by_css('.setting-input')[0].fill('2.34')
world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, "234", True) world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, "234", True)
world.save_component_and_reopen(step) world.save_component_and_reopen(step)
world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, "234", True) world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, "234", True)
@step('I set the max attempts to -3, the max attempts are persisted as 1') @step('I set the max attempts to -3, the max attempts are persisted as 1')
def set_max_attempts_to_neg_3(step): def set_max_attempts_to_neg_3(step):
world.get_setting_entry(MAXIMUM_ATTEMPTS).find_by_css('.setting-input')[0].fill('-3') world.get_setting_entry(MAXIMUM_ATTEMPTS).find_by_css('.setting-input')[0].fill('-3')
...@@ -145,7 +139,6 @@ def set_max_attempts_to_neg_3(step): ...@@ -145,7 +139,6 @@ def set_max_attempts_to_neg_3(step):
world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, "1", True) world.verify_setting_entry(world.get_setting_entry(MAXIMUM_ATTEMPTS), MAXIMUM_ATTEMPTS, "1", True)
@step('Edit High Level Source is not visible') @step('Edit High Level Source is not visible')
def edit_high_level_source_not_visible(step): def edit_high_level_source_not_visible(step):
verify_high_level_source(step, False) verify_high_level_source(step, False)
...@@ -182,12 +175,10 @@ def verify_modified_weight(): ...@@ -182,12 +175,10 @@ def verify_modified_weight():
world.verify_setting_entry(world.get_setting_entry(PROBLEM_WEIGHT), PROBLEM_WEIGHT, "3.5", True) world.verify_setting_entry(world.get_setting_entry(PROBLEM_WEIGHT), PROBLEM_WEIGHT, "3.5", True)
def verify_modified_randomization(): def verify_modified_randomization():
world.verify_setting_entry(world.get_setting_entry(RANDOMIZATION), RANDOMIZATION, "Per Student", True) world.verify_setting_entry(world.get_setting_entry(RANDOMIZATION), RANDOMIZATION, "Per Student", True)
def verify_modified_display_name(): def verify_modified_display_name():
world.verify_setting_entry(world.get_setting_entry(DISPLAY_NAME), DISPLAY_NAME, 'modified', True) world.verify_setting_entry(world.get_setting_entry(DISPLAY_NAME), DISPLAY_NAME, 'modified', True)
......
...@@ -10,9 +10,7 @@ from nose.tools import assert_equal ...@@ -10,9 +10,7 @@ from nose.tools import assert_equal
@step('I have opened a new course section in Studio$') @step('I have opened a new course section in Studio$')
def i_have_opened_a_new_course_section(step): def i_have_opened_a_new_course_section(step):
world.clear_courses() open_new_course()
log_into_studio()
create_a_course()
add_section() add_section()
......
...@@ -13,6 +13,7 @@ class UserFactory(sf.UserFactory): ...@@ -13,6 +13,7 @@ class UserFactory(sf.UserFactory):
""" """
User account for lms / cms User account for lms / cms
""" """
FACTORY_DJANGO_GET_OR_CREATE = ('username',)
pass pass
...@@ -21,6 +22,7 @@ class UserProfileFactory(sf.UserProfileFactory): ...@@ -21,6 +22,7 @@ class UserProfileFactory(sf.UserProfileFactory):
""" """
Demographics etc for the User Demographics etc for the User
""" """
FACTORY_DJANGO_GET_OR_CREATE = ('user',)
pass pass
...@@ -29,6 +31,7 @@ class RegistrationFactory(sf.RegistrationFactory): ...@@ -29,6 +31,7 @@ class RegistrationFactory(sf.RegistrationFactory):
""" """
Activation key for registering the user account Activation key for registering the user account
""" """
FACTORY_DJANGO_GET_OR_CREATE = ('user',)
pass pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment