'Verify that preview themes behaves correctly.'

def test_preview_theme(self):

    post_request = RequestFactory().post('/test')
    self.initialize_mock_request(post_request)
    set_user_preview_site_theme(post_request, TEST_THEME_NAME)
    get_request = self.create_mock_get_request()
    self.assertEqual(self.site_theme_middleware.process_request(get_request), None)
    self.assertEqual(get_request.site_theme.theme_dir_name, TEST_THEME_NAME)
    post_request = RequestFactory().post('/test')
    self.initialize_mock_request(post_request)
    set_user_preview_site_theme(post_request, None)
    get_request = self.create_mock_get_request()
    self.assertEqual(self.site_theme_middleware.process_request(get_request), None)
    self.assertIsNone(get_request.site_theme)
