Пример #1
0
def _sitedata_monkeypatch(site, *args, **kwargs):
    """
    Core functionality of decorators above.
    This monkeypatches Client or RequestFactory with the appropriate HTTP_HOST, and adds
    a SiteData instance as an attribute (so it can be looked at inside of a test).
    """
    sitedata = SiteData(label=site, require_exact_match=True)
    if 'client' in kwargs.keys():
        kwargs['client'] = Client(HTTP_HOST=sitedata.hostname)
        kwargs['client'].sitedata = sitedata
    if 'rf' in kwargs.keys():
        kwargs['rf'] = RequestFactory(HTTP_HOST=sitedata.hostname)
        kwargs['rf'].sitedata = sitedata
    return args, kwargs