You can do this as a one-liner:

    @mock.patch('xmodule.modulestore.django.get_current_request_hostname', Mock(return_value='preview.localhost'))