예제 #1
0
class TestWebServicePageIDs(TestCase):
    """Ensure that the web service enhances the page ID correctly."""
    def setUp(self):
        super(TestWebServicePageIDs, self).setUp()
        self.publication = WebServicePublication(db=None)
        self.view = FakeView()
        self.context = FakeContext()

    def makePageID(self):
        return self.publication.constructPageID(self.view, self.context)

    def test_pageid_without_op(self):
        # When the HTTP request does not have a named operation (ws.op) field
        # (either in the body or query string), the operation is included in
        # the page ID.
        self.assertEqual(self.makePageID(), 'FakeContext:FakeView')

    def test_pageid_without_op_in_form(self):
        # When the HTTP request does not have a named operation (ws.op) field
        # (either in the body or query string), the operation is included in
        # the page ID.
        self.view.request.form_values['ws.op'] = 'operation-name-1'
        self.assertEqual(self.makePageID(),
                         'FakeContext:FakeView:operation-name-1')

    def test_pageid_without_op_in_query_string(self):
        # When the HTTP request does not have a named operation (ws.op) field
        # (either in the body or query string), the operation is included in
        # the page ID.
        self.view.request.query_string_params['ws.op'] = 'operation-name-2'
        self.assertEqual(self.makePageID(),
                         'FakeContext:FakeView:operation-name-2')
예제 #2
0
class TestWebServicePageIDs(TestCase):
    """Ensure that the web service enhances the page ID correctly."""

    def setUp(self):
        super(TestWebServicePageIDs, self).setUp()
        self.publication = WebServicePublication(db=None)
        self.view = FakeView()
        self.context = FakeContext()

    def makePageID(self):
        return self.publication.constructPageID(self.view, self.context)

    def test_pageid_without_op(self):
        # When the HTTP request does not have a named operation (ws.op) field
        # (either in the body or query string), the operation is included in
        # the page ID.
        self.assertEqual(
            self.makePageID(), 'FakeContext:FakeView')

    def test_pageid_without_op_in_form(self):
        # When the HTTP request does not have a named operation (ws.op) field
        # (either in the body or query string), the operation is included in
        # the page ID.
        self.view.request.form_values['ws.op'] = 'operation-name-1'
        self.assertEqual(
            self.makePageID(), 'FakeContext:FakeView:operation-name-1')

    def test_pageid_without_op_in_query_string(self):
        # When the HTTP request does not have a named operation (ws.op) field
        # (either in the body or query string), the operation is included in
        # the page ID.
        self.view.request.query_string_params['ws.op'] = 'operation-name-2'
        self.assertEqual(
            self.makePageID(), 'FakeContext:FakeView:operation-name-2')
예제 #3
0
class TestCollectionResourcePageIDs(TestCase):
    """Ensure page ids for collections display the origin page resource."""
    def setUp(self):
        super(TestCollectionResourcePageIDs, self).setUp()
        self.publication = WebServicePublication(db=None)
        self.view = FakeCollectionResourceView()
        self.context = FakeContext()

    def makePageID(self):
        return self.publication.constructPageID(self.view, self.context)

    def test_origin_pageid_for_collection(self):
        # When the view provides a ICollectionResource, make sure the origin
        # page resource is included in the page ID.
        self.assertEqual(
            self.makePageID(),
            'FakeContext:FakeCollectionResourceView:#milestone-page-resource')
예제 #4
0
class TestPageIdCorners(TestCase):
    """Ensure that the page ID generation handles corner cases well."""
    def setUp(self):
        super(TestPageIdCorners, self).setUp()
        self.publication = WebServicePublication(db=None)
        self.view = FakeView()
        self.context = FakeContext()

    def makePageID(self):
        return self.publication.constructPageID(self.view, self.context)

    def test_pageid_with_multiple_op_fields(self):
        # The publisher will combine multiple form values with the same name
        # into a list.  If those values are for "ws.op", the page ID mechanism
        # should just ignore the op altogether.  (It used to generate an
        # error, see bug 810113).
        self.view.request.form_values['ws.op'] = ['one', 'another']
        self.assertEqual(self.makePageID(), 'FakeContext:FakeView')
예제 #5
0
class TestCollectionResourcePageIDs(TestCase):
    """Ensure page ids for collections display the origin page resource."""

    def setUp(self):
        super(TestCollectionResourcePageIDs, self).setUp()
        self.publication = WebServicePublication(db=None)
        self.view = FakeCollectionResourceView()
        self.context = FakeContext()

    def makePageID(self):
        return self.publication.constructPageID(self.view, self.context)

    def test_origin_pageid_for_collection(self):
        # When the view provides a ICollectionResource, make sure the origin
        # page resource is included in the page ID.
        self.assertEqual(
            self.makePageID(),
            'FakeContext:FakeCollectionResourceView:#milestone-page-resource')
예제 #6
0
class TestPageIdCorners(TestCase):
    """Ensure that the page ID generation handles corner cases well."""

    def setUp(self):
        super(TestPageIdCorners, self).setUp()
        self.publication = WebServicePublication(db=None)
        self.view = FakeView()
        self.context = FakeContext()

    def makePageID(self):
        return self.publication.constructPageID(self.view, self.context)

    def test_pageid_with_multiple_op_fields(self):
        # The publisher will combine multiple form values with the same name
        # into a list.  If those values are for "ws.op", the page ID mechanism
        # should just ignore the op altogether.  (It used to generate an
        # error, see bug 810113).
        self.view.request.form_values['ws.op'] = ['one', 'another']
        self.assertEqual(self.makePageID(), 'FakeContext:FakeView')