def test_create_or_update_section_assert_create_called_when_objectdoesnotexist_occurs(self, logger_mock, section_mock):
        """
        Test that create is called when the course does not exist.  When the 
        course does not exist the get call with throw an ObjectDoesNotExist
        exception. We set this as a side_effect of the get mock. 
        """
        get_mock = section_mock.objects.get
        create_mock = section_mock.objects.bulk_create
        set_disappearing_side_effect(get_mock, ObjectDoesNotExist)

        course_instance_mock = Mock(name="course_instance")
        sis_course_id = 3030303
        canvas_section_id = 1239
        section_name = 'test section'
        create_or_update_section(course_instance_mock, sis_course_id,
                                 canvas_section_id, section_name)
        self.assertEqual(create_mock.call_count, 1)
    def test_create_or_update_section_assert_save_called(self, logger_mock,
                                                         section_mock):
        """
        Test that save is called when the course exists, and create isn't.
        """
        course_instance_mock = Mock(name="course_instance")
        create_mock = section_mock.objects.bulk_create
        get_mock = section_mock.objects.get
        mock_section = Mock(spec=Section())
        save_mock = mock_section.save
        get_mock.return_value = mock_section

        sis_course_id = 3030303
        canvas_section_id = 1239
        section_name = 'test section'
        create_or_update_section(course_instance_mock, sis_course_id,
                                 canvas_section_id, section_name)

        self.assertEqual(create_mock.call_count, 0)
        self.assertEqual(save_mock.call_count, 1)