studio new style assumption corrections
This commit is contained in:
committed by
Diana Huang
parent
e39cc5dfa3
commit
1b71ace4b0
@@ -40,33 +40,34 @@ def check_has_course_method(modulestore, locator, locator_key_fields):
|
||||
assert_true(modulestore.has_course(locator, ignore_case))
|
||||
|
||||
for key_field in locator_key_fields:
|
||||
locator_changes_that_should_not_be_found = [ # pylint: disable=invalid-name
|
||||
# replace value for one of the keys
|
||||
{key_field: 'fake'},
|
||||
# add a character at the end
|
||||
{key_field: getattr(locator, key_field) + 'X'},
|
||||
# add a character in the beginning
|
||||
{key_field: 'X' + getattr(locator, key_field)},
|
||||
]
|
||||
for changes in locator_changes_that_should_not_be_found:
|
||||
search_locator = locator.replace(**changes)
|
||||
assert_false(
|
||||
modulestore.has_course(search_locator),
|
||||
error_message.format(search_locator, ignore_case)
|
||||
)
|
||||
if getattr(locator, key_field):
|
||||
locator_changes_that_should_not_be_found = [ # pylint: disable=invalid-name
|
||||
# replace value for one of the keys
|
||||
{key_field: 'fake'},
|
||||
# add a character at the end
|
||||
{key_field: getattr(locator, key_field) + 'X'},
|
||||
# add a character in the beginning
|
||||
{key_field: 'X' + getattr(locator, key_field)},
|
||||
]
|
||||
for changes in locator_changes_that_should_not_be_found:
|
||||
search_locator = locator.replace(**changes)
|
||||
assert_false(
|
||||
modulestore.has_course(search_locator),
|
||||
error_message.format(search_locator, ignore_case)
|
||||
)
|
||||
|
||||
# test case [in]sensitivity
|
||||
locator_case_changes = [
|
||||
{key_field: getattr(locator, key_field).upper()},
|
||||
{key_field: getattr(locator, key_field).capitalize()},
|
||||
{key_field: getattr(locator, key_field).capitalize().swapcase()},
|
||||
]
|
||||
for changes in locator_case_changes:
|
||||
search_locator = locator.replace(**changes)
|
||||
# if ignore_case is true, the course would be found with a different-cased course locator.
|
||||
# if ignore_case is false, the course should NOT found given an incorrectly-cased locator.
|
||||
assert_equals(
|
||||
modulestore.has_course(search_locator, ignore_case) is not None,
|
||||
ignore_case,
|
||||
error_message.format(search_locator, ignore_case)
|
||||
)
|
||||
# test case [in]sensitivity
|
||||
locator_case_changes = [
|
||||
{key_field: getattr(locator, key_field).upper()},
|
||||
{key_field: getattr(locator, key_field).capitalize()},
|
||||
{key_field: getattr(locator, key_field).capitalize().swapcase()},
|
||||
]
|
||||
for changes in locator_case_changes:
|
||||
search_locator = locator.replace(**changes)
|
||||
# if ignore_case is true, the course would be found with a different-cased course locator.
|
||||
# if ignore_case is false, the course should NOT found given an incorrectly-cased locator.
|
||||
assert_equals(
|
||||
modulestore.has_course(search_locator, ignore_case) is not None,
|
||||
ignore_case,
|
||||
error_message.format(search_locator, ignore_case)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user