def test_implied_subdomain_from_request(self):
        template = self.make_template('{% url view %}')
        defaults = {'view': 'home'}

        request = mock.Mock()
        request.subdomain = None

        context = Context(dict(defaults, request=request))
        rendered = template.render(context).strip()
        self.assertEqual(rendered, 'http://%s/' % self.DOMAIN)

        for subdomain in ('www', 'api', 'wildcard'):
            request = mock.Mock()
            request.subdomain = subdomain

            context = Context(dict(defaults, request=request))
            rendered = template.render(context).strip()
            self.assertEqual(rendered,
                'http://%s.%s/' % (subdomain, self.DOMAIN))
dataset/ETHPy150Open tkaemming/django-subdomains/subdomains/tests/tests.py/SubdomainTemplateTagTestCase.test_implied_subdomain_from_request/original