def test_check_name_uniqueness(self): success, name_unique = grader_util.check_name_uniqueness("temp", LOCATION, "course_id") self.assertTrue(name_unique) test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION, "PE") test_sub.save() test_sub = test_util.get_sub("PE", STUDENT_ID, LOCATION + "1", "PE") test_sub.save() success, name_unique = grader_util.check_name_uniqueness("id", LOCATION, "course_id") self.assertFalse(name_unique)
def verify_name_uniqueness(request): """ Check if a given problem name, location tuple is unique Input: A problem location and the problem name Output: Dictionary containing success, and and indicator of whether or not the name is unique """ if request.method != 'GET': return util._error_response("Request type must be GET", _INTERFACE_VERSION) for tag in ['location', 'problem_name', 'course_id']: if tag not in request.GET: return util._error_response("Missing required key {0}".format(tag), _INTERFACE_VERSION) location=request.GET.get("location") problem_name = request.GET.get("problem_name") course_id = request.GET.get('course_id') success, unique = grader_util.check_name_uniqueness(problem_name,location, course_id) if not success: return util._error_response(unique,_INTERFACE_VERSION) return util._success_response({ 'name_is_unique' : unique, }, _INTERFACE_VERSION)
def verify_name_uniqueness(request): """ Check if a given problem name, location tuple is unique Input: A problem location and the problem name Output: Dictionary containing success, and and indicator of whether or not the name is unique """ if request.method != 'GET': return util._error_response("Request type must be GET", _INTERFACE_VERSION) for tag in ['location', 'problem_name', 'course_id']: if tag not in request.GET: return util._error_response("Missing required key {0}".format(tag), _INTERFACE_VERSION) location=request.GET.get("location") problem_name = request.GET.get("problem_name") course_id = request.GET.get('course_id') success, unique = grader_util.check_name_uniqueness(problem_name,location, course_id) if not success: return util._error_response(eta,_INTERFACE_VERSION) return util._success_response({ 'name_is_unique' : unique, }, _INTERFACE_VERSION)