コード例 #1
0
 def test_create_section_status_on_empty_section_name(
         self, render_replacement):
     """Create Section should return 400 if the section name is empty"""
     request = self.create_section_request_stub()
     request.POST['section_name_input'] = ""
     create_section(request)
     render_replacement.assert_called_with(request, ANY, ANY, status=400)
コード例 #2
0
 def test_create_section_template_error_on_empty_section_name(
         self, render_replacement):
     """Create Section should render an error message if the section name is empty"""
     request = self.create_section_request_stub()
     request.POST['section_name_input'] = ""
     create_section(request)
     render_replacement.assert_called_with(
         request,
         'manage_sections/create_section_form.html',
         ANY,
         status=ANY)
 def test_create_section_section_name_whitespace_to_canvas(self, get_create_section, render_replacement):
     """Create Section trims extra whitespace before passing the section name to make the canvas call"""
     request = self.create_section_request_stub()
     request.POST['section_name_input'] = '   extra whitespace   '
     get_create_section.return_value = self.section
     response = create_section(request)
     get_create_section.assert_called_with(self.canvas_course_id, request.POST['section_name_input'].strip())
コード例 #4
0
 def test_create_section_status_on_whitespace_section_name(
         self, render_replacement):
     """Create Section should return 400 if the section name contains only whitespace"""
     request = self.create_section_request_stub()
     request.POST['section_name_input'] = "       "
     response = create_section(request)
     render_replacement.assert_called_with(request, ANY, ANY, status=400)
 def test_create_section_set_enrollment_called_with_0_value(self, get_create_section, render_replacement):
     """Test that create_section responds correctly"""
     request = self.create_section_request_stub()
     section_mock = MagicMock(name='section_mock')
     get_create_section.return_value = section_mock
     response = create_section(request)
     section_mock.__setitem__.assert_called_with('enrollment_count', 0)
コード例 #6
0
 def test_create_section_template_on_success(self, get_create_section,
                                             render_replacement):
     """Create Section renders the create section form on success"""
     request = self.create_section_request_stub()
     response = create_section(request)
     render_replacement.assert_called_with(
         request, 'manage_sections/section_list.html', ANY)
コード例 #7
0
 def test_create_section_section_name_to_canvas(self, get_create_section,
                                                render_replacement):
     """Create Section passes the correct section name to make the canvas call"""
     request = self.create_section_request_stub()
     response = create_section(request)
     get_create_section.assert_called_with(
         self.canvas_course_id, request.POST['section_name_input'])
コード例 #8
0
 def test_create_section_set_enrollment_called_with_0_value(
         self, get_create_section, render_replacement):
     """Test that create_section responds correctly"""
     request = self.create_section_request_stub()
     section_mock = MagicMock(name='section_mock')
     get_create_section.return_value = section_mock
     response = create_section(request)
     section_mock.__setitem__.assert_called_with('enrollment_count', 0)
コード例 #9
0
 def test_create_section_status_on_fail_return_500(self, get_create_section,
                                                   render_replacement):
     """Create Section returns 500 on failure"""
     request = self.create_section_request_stub()
     get_create_section.return_value = None
     response = create_section(request)
     render_replacement.assert_called_with(
         ANY, 'manage_sections/create_section_form.html', ANY, status=500)
コード例 #10
0
 def test_create_section_status_on_success(self, get_create_section,
                                           render_replacement):
     """Create Section returns 200 on success"""
     request = self.create_section_request_stub()
     get_create_section.return_value = self.section
     response = create_section(request)
     render_replacement.assert_called_with(
         ANY, 'manage_sections/section_list.html', ANY)
 def test_create_section_created_the_section_with_the_correct_data(self, get_create_section, render_replacement):
     """Create Section renders the correct section with the correct section data"""
     request = self.create_section_request_stub()
     get_create_section.return_value = {'sis_section_id': '123', 'enrollment_count': 0, 'section_id': 123, 'name': 'Test Name'}
     response = create_section(request)
     render_replacement.assert_called_with(request, 'manage_sections/section_list.html', {
         'section': get_create_section.return_value
     })
コード例 #12
0
 def test_create_section_section_name_whitespace_to_canvas(
         self, get_create_section, render_replacement):
     """Create Section trims extra whitespace before passing the section name to make the canvas call"""
     request = self.create_section_request_stub()
     request.POST['section_name_input'] = '   extra whitespace   '
     get_create_section.return_value = self.section
     response = create_section(request)
     get_create_section.assert_called_with(
         self.canvas_course_id, request.POST['section_name_input'].strip())
コード例 #13
0
 def test_create_section_created_the_section_with_the_correct_data(
         self, get_create_section, render_replacement):
     """Create Section renders the correct section with the correct section data"""
     request = self.create_section_request_stub()
     get_create_section.return_value = {
         'sis_section_id': '123',
         'enrollment_count': 0,
         'section_id': 123,
         'name': 'Test Name'
     }
     response = create_section(request)
     render_replacement.assert_called_with(
         request, 'manage_sections/section_list.html',
         {'section': get_create_section.return_value})
 def test_create_section_template_error_on_whitespace_section_name(self, render_replacement):
     """Create Section should render an error message if the section name contains only whitespace"""
     request = self.create_section_request_stub()
     request.POST['section_name_input'] = "       "
     response = create_section(request)
     render_replacement.assert_called_with(request, 'manage_sections/create_section_form.html', ANY, status=ANY)
 def test_create_section_section_name_to_canvas(self, get_create_section, render_replacement):
     """Create Section passes the correct section name to make the canvas call"""
     request = self.create_section_request_stub()
     response = create_section(request)
     get_create_section.assert_called_with(self.canvas_course_id, request.POST['section_name_input'])
 def test_create_section_status_on_success(self, get_create_section, render_replacement):
     """Create Section returns 200 on success"""
     request = self.create_section_request_stub()
     get_create_section.return_value = self.section
     response = create_section(request)
     render_replacement.assert_called_with(ANY, 'manage_sections/section_list.html', ANY)
 def test_create_section_status_on_whitespace_section_name(self, render_replacement):
     """Create Section should return 400 if the section name contains only whitespace"""
     request = self.create_section_request_stub()
     request.POST['section_name_input'] = "       "
     response = create_section(request)
     render_replacement.assert_called_with(request, ANY, ANY, status=400)
 def test_create_section_status_on_empty_section_name(self, render_replacement):
     """Create Section should return 400 if the section name is empty"""
     request = self.create_section_request_stub()
     request.POST['section_name_input'] = ""
     create_section(request)
     render_replacement.assert_called_with(request, ANY, ANY, status=400)
 def test_create_section_template_on_success(self, get_create_section, render_replacement):
     """Create Section renders the create section form on success"""
     request = self.create_section_request_stub()
     response = create_section(request)
     render_replacement.assert_called_with(request, 'manage_sections/section_list.html', ANY)
 def test_create_section_status_on_fail_return_500(self, get_create_section, render_replacement):
     """Create Section returns 500 on failure"""
     request = self.create_section_request_stub()
     get_create_section.return_value = None
     response = create_section(request)
     render_replacement.assert_called_with(ANY, 'manage_sections/create_section_form.html', ANY, status=500)
コード例 #21
0
 def test_create_section_instance_id_string_type_to_canvas(
         self, get_create_section, render_replacement):
     """Create Section passes the correct string-typed instance ID to make the canvas call"""
     request = self.create_section_request_stub()
     create_section(request)
     get_create_section.assert_called_with(self.canvas_course_id, ANY)
 def test_create_section_instance_id_string_type_to_canvas(self, get_create_section, render_replacement):
     """Create Section passes the correct string-typed instance ID to make the canvas call"""
     request = self.create_section_request_stub()
     create_section(request)
     get_create_section.assert_called_with(self.canvas_course_id, ANY)