Пример #1
0
 def get_api_list(self):
     """
     convenience function to get list of all api
     """
     c = Client()
     r = c.get("/api/")
     print "API List:", r.content
Пример #2
0
class AlertTest(TestCase):
    fixtures = ["test_court.json", "authtest_data.json"]

    def setUp(self):
        # Set up some handy variables
        self.client = Client()
        self.alert_params = {"query": "q=asdf", "name": "dummy alert", "rate": "dly"}

    def test_create_alert(self):
        """Can we create an alert by sending a post?"""
        self.client.login(username="pandora", password="password")
        r = self.client.post(reverse("show_results"), self.alert_params, follow=True)
        self.assertEqual(r.redirect_chain[0][1], 302)
        self.assertIn("successfully", r.content)
        self.client.logout()

    def test_fail_gracefully(self):
        """Do we fail gracefully when an invalid alert form is sent?"""
        # Use a copy to shield other tests from changes.
        bad_alert_params = self.alert_params.copy()
        # Break the form
        bad_alert_params.pop("query", None)
        self.client.login(username="pandora", password="password")
        r = self.client.post("/", bad_alert_params, follow=True)
        self.assertEqual(r.status_code, 200)
        self.assertIn("error creating your alert", r.content)
        self.client.logout()
Пример #3
0
 def test_json_html(self):
     client = Client()
     data = '{"id":"jsonrpc", "params":[], "method":"collector.getTagList", "jsonrpc":"1.0"}'
     response = client.post(
         "/collector/json/", data, content_type="text/plain", HTTP_X_REQUESTED_WITH="XMLHttpRequest"
     )
     self.assertEqual("", repr(response.content))
Пример #4
0
    def test_registrations(self):
        """  Проверка страницы регистрации """

        self.post = {
            "email": "test@test.ru",
            "password": "1233456",
            "password_confirm": "1233456",
            "surname": "Иванов",
            "name": "Иван",
            "second_name": "Иванович",
            "description": "Нет описания",
            "testing_types": ["4"],
            "os": ["1", "2"],
            "program_languages": ["6"],
            "browsers": ["3", "4"],
        }
        c = Client()

        response = c.get("/accounts/testers/register")
        self.assertContains(response, "Регистрация тестировщика")
        self.assertEqual(response.status_code, 200)

        # self.assertEqual(len(mail.outbox), 1)
        # self.assertEqual(mail.outbox[0].subject, 'Test message')
        # self.assertEqual(mail.outbox[0].body, 'This is a test email')
        # self.assertEqual(mail.outbox[0].from_email, 'from@example.com')
        # self.assertEqual(mail.outbox[0].to[0], self.get1['email'])

        response = c.post("/accounts/testers/register", self.post)
        self.assertRedirects(response, "/accounts/thanks")
Пример #5
0
class ArticleViewTest(TestCase):
    def setUp(self):
        self.client = Client()
        testauthor = User.objects.create(username="testuser")
        self.article = Article.objects.create(
            title="Testarticle", content="<p>News here</p>", published_date=now(), author=testauthor
        )
        InstagramMedia.objects.create(
            media_type="image",
            poster="ntnuitaadmin",
            poster_image="/admin.png",
            thumbnail_url="/thumb.jpg",
            media_url="/fullsize.jpg",
            like_count=1337,
            caption="Snow and awesome stuff this weekend with #ntnuita",
            created_time=datetime.datetime.now(),
            instagram_id="cafed00d",
        )

    def test_get_frontpage(self):
        response = self.client.get("/")
        self.assertEqual(response.status_code, 200)
        self.assertTrue("Testarticle" in response.content.decode("utf-8"))
        self.assertTrue("<p>News here</p>" in response.content.decode("utf-8"))
        self.assertTrue("Snow and awesome" in response.content.decode("utf-8"))

    def test_get_article_details(self):
        response = self.client.get("/articles/%d" % self.article.id)
        self.assertEqual(response.status_code, 200)
        self.assertTrue("Testarticle" in response.content.decode("utf-8"))
        self.assertTrue("<p>News here</p>" in response.content.decode("utf-8"))
 def test_NavigationHome(self):
     """
     Checks whether all the pages are navigable or not.
     """
     c = Client()
     response = c.post("/Online_transactions/")
     self.assertEqual(response.status_code, 200)
Пример #7
0
 def test_no_login(self):
     urls = ["/", "/classes/", "/event/", "/thing/"]
     client = Client()
     for u in urls:
         response = client.get(u)
         self.assertEqual(response.status_code, 200)
     self.assertEqual(client.get("/nosuchpageexistsoreverexisted/").status_code, 404)
Пример #8
0
 def setUp(self):
     self.anon_user = Client()
     self.logged_in_user1 = Client()
     self.logged_in_user2 = Client()
     joe = User.objects.create_user(username="joe", password="joespw")
     self.knut = User.objects.create_user(username="knut", password="knutspw")
     arrkom = Group.objects.create(name="Arrkom")
     arrkom.permissions.add(Permission.objects.get(codename="early_signup"))
     self.knut.groups.add(arrkom)
     self.logged_in_user1.login(username="joe", password="joespw")
     self.logged_in_user2.login(username="knut", password="knutspw")
     self.no_signup_time_event = Event.objects.create(
         name="Testevent",
         startdate=(datetime.now() + timedelta(days=3)),
         enddate=(datetime.now() + timedelta(days=3, hours=5)),
         has_registration=True,
     )
     self.single_spot_event = Event.objects.create(
         name="Testevent",
         startdate=(datetime.now() + timedelta(days=1)),
         enddate=(datetime.now() + timedelta(days=2)),
         has_registration=True,
         registration_opens=(datetime.now() - timedelta(minutes=10)),
         number_of_spots=1,
     )
     self.event_with_presignups = Event.objects.create(
         name="Other testevent",
         startdate=(datetime.now() + timedelta(days=3)),
         registration_opens=(datetime.now() + timedelta(days=2)),
         has_registration=True,
         enddate=(datetime.now() + timedelta(days=4)),
     )
     self.event_with_presignups._add_user(joe)
Пример #9
0
class UrlTest(TestCase):
    def setUp(self):
        self.client = Client()

    def test_index(self):
        response = self.client.get("/")
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, "blog/index.html")

    def test_entry(self):
        response = self.client.get("/entry/")
        # If no id is passed then 404
        self.assertEqual(response.status_code, 404)
        self.assertTemplateNotUsed(response, "blog/entry.html")

    def test_author(self):
        response = self.client.get("/author/")
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, "blog/author.html")

    def test_category(self):
        response = self.client.get("/categories/")
        # If no id is passed then 404
        self.assertEqual(response.status_code, 404)
        self.assertTemplateNotUsed(response, "blog/category.html")

    def test_tag(self):
        response = self.client.get("/tags/")
        # If no id is passed then 404
        self.assertEqual(response.status_code, 404)
        self.assertTemplateNotUsed(response, "blog/category.html")
Пример #10
0
    def test_add_by_view(self):
        cli_anon = Client()
        cli_user1 = Client()
        self.assert_(cli_user1.login(username="testuser", password=u"pasło"))
        # We also test different ways of URL resolving here
        self._test_status(
            reverse("satchless-cart-view", kwargs={"typ": "satchless_cart"}), client_instance=cli_anon, status_code=200
        )
        self._test_status(reverse("satchless-cart-view"), client_instance=cli_anon, status_code=200)
        self._test_status(
            reverse("satchless-cart-view", kwargs={"typ": "satchless_cart"}), client_instance=cli_user1, status_code=200
        )

        self._test_status(
            self.macaw.get_absolute_url(),
            method="post",
            data={"typ": "satchless_cart", "color": "blue", "looks_alive": 1, "quantity": 1},
            client_instance=cli_anon,
            status_code=302,
        )
        self._test_status(
            self.cockatoo.get_absolute_url(),
            method="post",
            data={"typ": "satchless_cart", "color": "white", "looks_alive": 1, "quantity": 10},
            client_instance=cli_user1,
            status_code=302,
        )
Пример #11
0
 def setUp(self):
     self.anon_user = Client()
     self.logged_in_user = Client()
     self.committee_member1 = Client()
     self.committee_member2 = Client()
     User.objects.create_user(username="joe", password="joespw")
     committee_member1 = User.objects.create_user(username="arnulf", password="arnulfspw")
     committee_member2 = User.objects.create_user(username="øverland", password="øverlandspw")
     arrkom = Group.objects.create(name="Arrkom")
     arrkom.permissions.add(Permission.objects.get(codename="early_signup"))
     committee_member1.groups.add(arrkom)
     committee_member2.groups.add(arrkom)
     self.logged_in_user.login(username="joe", password="joespw")
     self.committee_member1.login(username="arnulf", password="arnulfspw")
     self.committee_member2.login(username="øverland", password="øverlandspw")
     self.event = Event.objects.create(
         name="Testevent",
         startdate=(datetime.now() + timedelta(days=3)),
         enddate=(datetime.now() + timedelta(days=3, hours=5)),
         has_registration=True,
         number_of_spots=3,
         registration_opens=(datetime.now() + timedelta(days=1)),
         registration_closes=(datetime.now() + timedelta(days=2)),
         _comittee_registration_opens=(datetime.now() - timedelta(hours=2)),
     )
Пример #12
0
 def test_register_modal_returns_correct_html(self):
     client = Client()
     response = client.post("/register_modal")
     self.assertEqual(response.status_code, 200)
     self.assertTrue(response.content.startswith(b"<div"))
     self.assertIn(b"register_modal", response.content)
     self.assertIn(b"register_form", response.content)
Пример #13
0
class CMSViewTest(TestCase):
    urls = "socialapps.cms.tests.urls"

    def setUp(self):
        self.client = Client()
        user = User.objects.create_user("user", "dummy@mail.com", "password")
        self.client.login(username="user", password="password")

    def test_list_views(self):
        folder = Folder.objects.create(title="folder 1", status=1, portal_type="folder")
        folder.save()
        response = self.client.get(reverse("base_view", kwargs={"path": "folder-1/"}))
        self.assertTemplateUsed(response, "cms/folder.html")

        folder2 = Folder.objects.create(title="folder 2", status=1, portal_type="folder", parent=folder)
        folder2.save()
        response = self.client.get(reverse("base_view", kwargs={"path": "folder-1/folder-2/"}))
        self.assertTemplateUsed(response, "cms/folder.html")

        children = folder.get_children()
        self.assertTrue(folder2 in [c.get_type_object() for c in children])

    def test_edit_view(self):
        folder = Folder.objects.create(title="folder 1", status=1, portal_type="folder")
        folder.save()
        response = self.client.get(reverse("base_edit", kwargs={"path": "folder-1/"}))
        self.assertTemplateUsed(response, "cms/edit_form.html")
Пример #14
0
class TestContentParsingWithAuthentication(TestCase):
    urls = "djangorestframework.tests.content"

    def setUp(self):
        self.csrf_client = Client(enforce_csrf_checks=True)
        self.username = "john"
        self.email = "lennon@thebeatles.com"
        self.password = "password"
        self.user = User.objects.create_user(self.username, self.email, self.password)
        self.req = RequestFactory()

    def test_user_logged_in_authentication_has_post_when_not_logged_in(self):
        """Ensures request.POST exists after UserLoggedInAuthentication when user doesn't log in"""
        content = {"example": "example"}

        response = self.client.post("/", content)
        self.assertEqual(status.OK, response.status_code, "POST data is malformed")

        response = self.csrf_client.post("/", content)
        self.assertEqual(status.OK, response.status_code, "POST data is malformed")

    def test_user_logged_in_authentication_has_post_when_logged_in(self):
        """Ensures request.POST exists after UserLoggedInAuthentication when user does log in"""
        self.client.login(username="john", password="password")
        self.csrf_client.login(username="john", password="password")
        content = {"example": "example"}

        response = self.client.post("/", content)
        self.assertEqual(status.OK, response.status_code, "POST data is malformed")

        response = self.csrf_client.post("/", content)
        self.assertEqual(status.OK, response.status_code, "POST data is malformed")
class BasicAuthTests(TestCase):
    """Basic authentication"""

    urls = "rest_framework.tests.authentication"

    def setUp(self):
        self.csrf_client = Client(enforce_csrf_checks=True)
        self.username = "john"
        self.email = "lennon@thebeatles.com"
        self.password = "password"
        self.user = User.objects.create_user(self.username, self.email, self.password)

    def test_post_form_passing_basic_auth(self):
        """Ensure POSTing json over basic auth with correct credentials passes and does not require CSRF"""
        auth = "Basic %s" % base64.encodestring("%s:%s" % (self.username, self.password)).strip()
        response = self.csrf_client.post("/", {"example": "example"}, HTTP_AUTHORIZATION=auth)
        self.assertEqual(response.status_code, 200)

    def test_post_json_passing_basic_auth(self):
        """Ensure POSTing form over basic auth with correct credentials passes and does not require CSRF"""
        auth = "Basic %s" % base64.encodestring("%s:%s" % (self.username, self.password)).strip()
        response = self.csrf_client.post(
            "/", json.dumps({"example": "example"}), "application/json", HTTP_AUTHORIZATION=auth
        )
        self.assertEqual(response.status_code, 200)

    def test_post_form_failing_basic_auth(self):
        """Ensure POSTing form over basic auth without correct credentials fails"""
        response = self.csrf_client.post("/", {"example": "example"})
        self.assertEqual(response.status_code, 403)

    def test_post_json_failing_basic_auth(self):
        """Ensure POSTing json over basic auth without correct credentials fails"""
        response = self.csrf_client.post("/", json.dumps({"example": "example"}), "application/json")
        self.assertEqual(response.status_code, 403)
Пример #16
0
class PingTest(TestCase):

    """Simple ping."""

    def setUp(self):
        """Setup."""
        self.c = Client(HTTP_HOST=settings.RSR_DOMAIN)
        iati_version = Version(code=settings.IATI_VERSION)
        iati_version.save()

        self.resp = self.c.get("/projects/")
        self.en_resp = self.c.get("/en/projects/")
        self.es_resp = self.c.get("/es/projects/")

    def test_ping(self):
        """Ping /projects/."""
        self.assertEqual(self.en_resp.status_code, 200)
        self.assertEqual(self.es_resp.status_code, 200)

    def test_redirect(self):
        """Test /projects/ redirect"""
        self.assertEqual(self.resp.status_code, 302)

    def test_template_markup(self):
        """Check for common template errors."""
        self.assertFalse(contains_template_errors(self.resp.content))
 def setUp(self):
     self.csrf_client = Client(enforce_csrf_checks=True)
     self.non_csrf_client = Client(enforce_csrf_checks=False)
     self.username = "john"
     self.email = "lennon@thebeatles.com"
     self.password = "password"
     self.user = User.objects.create_user(self.username, self.email, self.password)
Пример #18
0
    def test_goal_complete_page_returns_correct_html_for_credit_goal(self):
        client = Client()
        client.login(username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD)

        # Create a 'SavingsGoal' which had 30 days pass by and the goal is
        # ready to be evaluated as either completed or failed.
        CreditGoal.objects.create(
            id=1,
            user=User.objects.get(username=TEST_USER_USERNAME),
            created="2016-02-01T18:51:20.925Z",
            is_locked=True,
            unlocks="2016-02-01T18:51:20.925Z",
            is_closed=True,
            was_accomplished=True,
            earned_xp=25,
        )

        response = client.get("/en/mygoals/" + str(constants.CREDIT_MYGOAL_TYPE) + "/1/complete")
        self.assertEqual(response.status_code, 200)
        self.assertTrue(len(response.content) > 1)

        # Verify the links to the three different type of Goals exist
        # in this page for the User to access.
        self.assertIn(b"Congratulations", response.content)
        self.assertIn(b"You completed your goal, this is awesome!", response.content)
        self.assertIn(b"/en/mygoals/credit", response.content)
Пример #19
0
    def test_add_interbank_party(self):
        """
        Test case for adding a interbank party
        """

        c = Client()
        response = c.post("/home_page", {"user_id": "test_user1", "passwd": "test_passwd"})
        self.assertEqual(response.status_code, 301)

        response = c.post("/interbank_transfer2/")

        response = c.post(
            "/add_other_bank_account/",
            {
                "name": "interbank_beneficiery_1",
                "account_no": "50001",
                "line1": "flat no 7",
                "line2": "J 8/1 Paras",
                "line3": "delhi",
                "account_no_2": "50001",
                "limit": 15000,
                "IFSC": "901",
            },
        )
        account = Connected_Account.objects.filter(ca_connected_acc_no="50001")
        self.assertEqual(account.name, "interbank_beneficiery_1")
Пример #20
0
    def test_mygoals_final_page_returns_correct_html_for_goal_is_completed(self):
        client = Client()
        client.login(username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD)

        # Create a 'SavingsGoal' which had 30 days pass by and the goal is
        # ready to be evaluated as either completed or failed.
        FinalGoal.objects.create(
            id=1,
            user=User.objects.get(username=TEST_USER_USERNAME),
            created="2016-02-01T18:51:20.925Z",
            is_locked=True,
            unlocks="2016-02-01T18:51:20.925Z",
            is_closed=False,
            was_accomplished=False,
            earned_xp=25,
        )

        response = client.get("/en/mygoals/final")  # Call the URL.

        # Verify the URL results.
        self.assertEqual(response.status_code, 200)
        self.assertTrue(len(response.content) > 1)
        self.assertIn(b"Goal", response.content)
        self.assertIn(b"I want to save", response.content)
        self.assertIn(b"ajax_finish_final_goal", response.content)
 def test_no_diazo(self):
     c = Client()
     # response = c.get('{0}/'.format(LIVE_SERVER_URL), {})
     response = c.get("{0}/".format(""), {})
     self.assertTrue(response.status_code in (200, 201, 202))
     response_content = clean_xml_content(clean_extra_spaces(response.content))
     self.assertTrue(response_content == original_xml)
Пример #22
0
    def test_goal_failed_page_returns_correct_html_for_final_goal(self):
        client = Client()
        client.login(username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD)

        # Create a 'SavingsGoal' which had 30 days pass by and the goal is
        # ready to be evaluated as either completed or failed.
        FinalGoal.objects.create(
            id=1,
            user=User.objects.get(username=TEST_USER_USERNAME),
            created="2016-02-01T18:51:20.925Z",
            is_locked=True,
            unlocks="2016-02-01T18:51:20.925Z",
            is_closed=True,
            was_accomplished=False,
            earned_xp=25,
        )

        response = client.get("/en/mygoals/" + str(constants.GOAL_MYGOAL_TYPE) + "/1/sorry")
        self.assertEqual(response.status_code, 200)
        self.assertTrue(len(response.content) > 1)

        # Verify the links to the three different type of Goals exist
        # in this page for the User to access.
        self.assertIn(b"Sorry", response.content)
        self.assertIn(b"Do not worry! There is always next time. Please try again!", response.content)
        self.assertIn(b"/en/mygoals/final", response.content)
Пример #23
0
class AllArticlesTest(TestCase):
    def setUp(self):
        self.client = Client()
        testauthor = User.objects.create(username="testuser")
        for i in range(10):
            Article.objects.create(
                title="Article #%d" % i,
                content="<p>%d</p>" % i,
                published_date=(now() - datetime.timedelta(hours=i)),
                author=testauthor,
            )

    def test_get_all_articles(self):
        response = self.client.get("/articles")
        self.assertEqual(response.status_code, 200)
        for i in range(10):
            self.assertTrue("Article #%s" % i in response.content.decode("utf-8"))
            self.assertTrue("<p>%d</p>" % i in response.content.decode("utf-8"))

    def test_get_with_limits_json(self):
        last_article_on_frontpage = Article.objects.get(title="Article #5")
        before = last_article_on_frontpage.published_date.isoformat()
        response = self.client.get("/articles", {"before": before, "limit": 1}, HTTP_ACCEPT="application/json")
        self.assertEqual(response.status_code, 200)
        self.assertTrue("Article #6" in response.content.decode("utf-8"))
        self.assertTrue("<p>6</p>" in response.content.decode("utf-8"))
        self.assertFalse("Article #7" in response.content.decode("utf-8"))
Пример #24
0
 def test_login_sso_redirects_to_home_when_no_service(self):
     user = User.objects.create_user(
         first_name="foo", username="foo@example.com", email="foo@example.com", password="1234"
     )
     client = Client()
     response = client.post(("/login?service=None"), {"username": user.username, "password": "1234"}, follow=True)
     self.assertRedirects(response, "/")
Пример #25
0
class TestAjaxRequests(TestCase):
    def setUp(self):
        self.client = Client()
        self.user = User.objects.create(
            username="test@test.com", email="test@test.com", password=User.objects.make_random_password()
        )
        self.channel = Channel.objects.create(
            name="test channel 2", slug="test-channel-2", user=self.user, published=True, date_available=timezone.now()
        )
        self.post = Post.objects.create(
            headline=u"a simple headline 2",
            short_title=u"a simple short title 2",
            title=u"a simple title 2",
            hat=u"a simple hat 2",
            channel=self.channel,
            user=self.user,
            published=True,
            date_available=timezone.now(),
        )

    def test_if_ajax_extends_variable_in_context_is_empty_without_ajax(self):
        response = self.client.get(self.post.get_absolute_url())
        self.assertTrue(response)
        self.assertEqual(response.status_code, 200)

    def test_get_ajax_extends_variable_in_context(self):
        response = self.client.get(self.post.get_absolute_url(), HTTP_X_REQUESTED_WITH="XMLHttpRequest")
        self.assertTrue(response)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context["extends_parent"], "base_ajax.html")
Пример #26
0
    def test_ort(self):
        client = Client()
        response = client.get("/orte/")
        self.assertEqual(response.status_code, 200)

        response = client.get("/orte/1/")
        self.assertEqual(response.status_code, 200)
Пример #27
0
    def test_remove_task(self):
        """
        Test that the task is removed from list properly.
        """
        task_id = self.create_task(
            {
                "task_info": {
                    "repo_slug": self.repo.slug,
                    # No ids to export, but task should still run.
                    "ids": [],
                },
                "task_type": EXPORT_TASK_TYPE,
            }
        )["id"]
        self.assertEqual(self.get_task(task_id)["status"], "success")

        # Other users can't stop tasks they don't own.
        client2 = Client()
        client2.login(username=self.user_norepo.username, password=self.PASSWORD)
        resp = client2.delete("{base}tasks/{task_id}/".format(base=API_BASE, task_id=task_id))
        self.assertEqual(resp.status_code, HTTP_404_NOT_FOUND)

        self.delete_task(task_id)
        self.get_task(task_id, expected_status=HTTP_404_NOT_FOUND)
        self.assertEqual(self.get_tasks()["count"], 0)
Пример #28
0
def login(username, password):
    """Log a user in.

    This is for use on a login that is supposed to succeed. It checks the
    system response with asserts before returning.

    :param username: The username to use
    :type username: str
    :param password: The password to use
    :type password: str
    :return: If a successful login, the authorization token's value
    :rtype: str

    """
    from django.test import Client

    # Log the user in, and return the auth token's value.
    client = Client()
    response = client.post(LOGIN_URL, {"username": username, "password": password})

    # pylint: disable=E1101
    assert response.status_code == HTTP_200_OK
    assert isinstance(response.data["auth_token"], basestring)

    return response.data["auth_token"]  # pylint: disable=E1101
Пример #29
0
class ExchangeTestCase(SimpleTestCase):
    def setUp(self):
        self.client = Client()

    def test_exchange(self):
        user = User(id="102", username="123", password="123")
        user.save()
        request_data = {"userid": "102", "prop": "123", "amount": "2", "score": "300"}
        response = self.client.post(
            "/store/Exchange_prop/", json.JSONEncoder().encode(request_data), "application/json"
        )
        data = response.content.decode("utf-8")
        self.assertEqual(data, "noscore")

        userinfo = User_info(userid="102", score="500")
        userinfo.save()
        response2 = self.client.post(
            "/store/Exchange_prop/", json.JSONEncoder().encode(request_data), "application/json"
        )
        data2 = response2.content.decode("utf-8")
        self.assertEqual(data2, "success")

        user = User(id="103", username="1234", password="123")
        user.save()
        userinfo = User_info(userid="103", score="100")
        userinfo.save()
        request_data = {"userid": "103", "prop": "123", "amount": "2", "score": "300"}
        response3 = self.client.post(
            "/store/Exchange_prop/", json.JSONEncoder().encode(request_data), "application/json"
        )
        data3 = response3.content.decode("utf-8")
        self.assertEqual(data3, "noscore")
Пример #30
0
    def test_final_quest_results_view(self):
        u1 = self._get_player(1).get_extension(QuestUser)
        u2 = self._get_player(2).get_extension(QuestUser)
        r = Race.objects.create(name="rasa_buna", can_play=True)
        Formula.add("finalquest-ok", expression="points=50*({level}+1)/{level_users}")
        Formula.add("level-gold", expression="gold=0")
        Coin.add("points")
        Coin.add("gold")
        final = FinalQuest.objects.create(start=datetime.datetime.now(), end=datetime.datetime.now())
        question = Question.objects.create(text="test", answer_type="F")
        final.questions.add(question)
        question = Question.objects.create(text="test", answer_type="F")
        final.questions.add(question)

        u1.current_level = 1
        u1.race = r
        u1.current_quest = final
        u1.save()
        u2.current_level = 1
        u2.race = r
        u2.current_quest = final
        u2.save()

        c = Client()
        admin = User.objects.create_superuser("admin", "admin@myemail.com", "admin")
        c.login(username="admin", password="admin")
        response = c.get("/cpanel/games/quest/final/results/")
        self.assertContains(response, "testuser1")
        self.assertContains(response, "testuser2")