Ejemplo n.º 1
0
    def test_navigate_to_first_page_complex(self):
        """Navigate to the first page, even if this doesn't have sequence 1
        """
        page_1_id = Test.get_first_page_for(self.test1.id)
        self.test1.page_set.first().delete()

        first_page_id = Test.get_first_page_for(self.test1.id)
        self.assertNotEqual(page_1_id, first_page_id)
        response = self._get_response(test_id=self.test1.id,
                                      page_id=first_page_id)
        self.assertEqual(200, response.status_code)
Ejemplo n.º 2
0
def is_page_sequence_valid(test_id, page_id, last_test_id, last_page_id):
    """Checks whether the current test page is in the right sequence with
    regards to the last.

    Given the current test_id and page_id, this function checks the
    HTTP_REFERER (last page) to see if

    :param last_test_id:
    :param referer:
    """
    # test_session = TestSession(request.session)
    # if test_session is None:
    #     raise KeyError('Unable to determine page sequence')

    # last_test_id, last_page_id = test_session.get_last_test_page()
    #check if first page is right
    if last_page_id is None:
        return int(page_id) == Test.get_first_page_for(test_id)

    if last_page_id == page_id:
        return True

    #check if next page is right (next or results page)
    if int(page_id) != get_next_page(last_test_id, last_page_id):
        return False

    return True
Ejemplo n.º 3
0
 def test_navigation_to_first_page_simple(self):
     """Navigate to first page (by coincidence page 1)
     """
     first_page_id = Test.get_first_page_for(self.test1.id)
     response = self._get_response(test_id=self.test1.id,
                                   page_id=first_page_id)
     self.assertEqual(200, response.status_code)