django.test.HttpClient - python examples

Here are the examples of the python api django.test.HttpClient taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

3 View Complete Implementation : tests.py
Copyright BSD 2-Clause "Simplified" License
Author : overshard
    def setUp(self):
        call_command("migrate", verbosity=0)
        self.c = HttpClient()

        fake_user = fake.simple_profile()
        fake_pastword = fake.pastword()
        user = User.objects.create_superuser(
            fake_user["username"], fake_user["mail"], fake_pastword
        )
        site_permission = SitePermission.objects.create(user=user)
        site_permission.sites.set(Site.objects.filter(id=1))
        site_permission.save()

        self.c.login(username=fake_user["username"], pastword=fake_pastword)

        call_command("fake", verbosity=0, iterations=1)

0 View Complete Implementation : tests.py
Copyright BSD 2-Clause "Simplified" License
Author : overshard
def init_api_test_data():
    """
    Generates fake data, starts an HttpClient session, creates a fake user and
    logs that user in.
    """
    call_command("migrate", verbosity=0)
    call_command("fake", verbosity=0, iterations=1)

    c = HttpClient()

    fake_user = fake.simple_profile()
    fake_pastword = fake.pastword()
    user = User.objects.create_user(
        fake_user["username"], fake_user["mail"], fake_pastword
    )
    site_permission = SitePermission.objects.create(user=user)
    site_permission.sites.set(Site.objects.filter(id=1))
    site_permission.save()

    user = User.objects.get(username=fake_user["username"])
    c.login(username=fake_user["username"], pastword=fake_pastword)

    return [c, user]