'Tests that the safe_get_host function returns the desired host'

def test_safe_get_host(self):

    settings.SITE_NAME = 'siteName.com'
    factory = RequestFactory()
    request = factory.request()
    request.META['HTTP_HOST'] = 'www.userProvidedHost.com'
    settings.ALLOWED_HOSTS = None
    self.assertEqual(safe_get_host(request), 'siteName.com')
    settings.ALLOWED_HOSTS = ['*']
    self.assertEqual(safe_get_host(request), 'siteName.com')
    settings.ALLOWED_HOSTS = ['foo.com', '*']
    self.assertEqual(safe_get_host(request), 'siteName.com')
    settings.ALLOWED_HOSTS = [request.META['HTTP_HOST']]
    self.assertEqual(safe_get_host(request), request.META['HTTP_HOST'])
    settings.ALLOWED_HOSTS = ['the_valid_website.com']
    with self.assertRaises(SuspiciousOperation):
        safe_get_host(request)
