Esempio n. 1
0
def test_batch():

    sequence = [1, 3, 5, 7, 9, 11, 13, 15]

    class Publishable(Location):
        implements(IPublicationRoot)

    root = Publishable()
    request = TestRequest()
    batcher = Batcher(root, request)
    batcher.update(sequence)
    assert not XMLDiff(batcher.render(), NO_BATCH)

    request = TestRequest(form={'batch.size': 2})
    batcher = Batcher(root, request)
    batcher.update(sequence)
    assert not XMLDiff(batcher.render(), BATCHED)

    request = TestRequest(form={'batch.size': 2, 'batch.start': 4})
    batcher = Batcher(root, request)
    batcher.update(sequence)
    assert not XMLDiff(batcher.render(), BATCHED_ADV)
Esempio n. 2
0
def test_batch_multi_param():

    sequence = range(10)
    
    class Publishable(Location):
        implements(IPublicationRoot)

    root = Publishable()
    request = TestRequest(
                form={'batch.size': 2, 'batch.start': 4, 'x':[u'a', u'b']})
    batcher = Batcher(root, request)
    batcher.update(sequence)
    assert ('http://localhost?x=a&x=b&batch.start=0&batch.size=2'
            in batcher.render())
Esempio n. 3
0
def test_batch():

    sequence = [1, 3, 5, 7, 9, 11, 13, 15]

    @implementer(IPublicationRoot)
    class Publishable(Location):
        pass

    root = Publishable()
    request = Request()
    batcher = Batcher(root, request)
    batcher.update(sequence)
    assert not XMLDiff(batcher.render(), NO_BATCH)

    request = Request(form={'batch.size': 2})
    batcher = Batcher(root, request)
    batcher.update(sequence)
    assert not XMLDiff(batcher.render(), BATCHED)

    request = Request(form={'batch.size': 2, 'batch.start': 4})
    batcher = Batcher(root, request)
    batcher.update(sequence)
    assert not XMLDiff(batcher.render(), BATCHED_ADV)
Esempio n. 4
0
def test_batch_unicode_param():

    sequence = range(10)
    
    class Publishable(Location):
        implements(IPublicationRoot)

    root = Publishable()
    request = TestRequest(
                form={'batch.size': 2, 'batch.start': 4, 'x':u'héhô'})
    batcher = Batcher(root, request)
    batcher.update(sequence)
    content = batcher.render()  # must not raise
    # assert page param is url encoded
    assert 'http://localhost?x=h%C3%A9h%C3%B4' in content
Esempio n. 5
0
def test_batch_unicode_param():

    sequence = range(10)

    @implementer(IPublicationRoot)
    class Publishable(Location):
        pass

    root = Publishable()
    request = Request(form={'batch.size': 2, 'batch.start': 4, 'x': u'héhô'})
    batcher = Batcher(root, request)
    batcher.update(sequence)
    content = batcher.render()  # must not raise
    # assert page param is url encoded
    assert 'http://localhost?x=h%C3%A9h%C3%B4' in content
Esempio n. 6
0
def test_batch_multi_param():

    sequence = range(10)

    @implementer(IPublicationRoot)
    class Publishable(Location):
        pass

    root = Publishable()
    request = Request(form={
        'batch.size': 2,
        'batch.start': 4,
        'x': [u'a', u'b']
    })
    batcher = Batcher(root, request)
    batcher.update(sequence)
    assert ('http://localhost?x=a&x=b&batch.start=0&batch.size=2'
            in batcher.render())