コード例 #1
0
    def post(self):
        # Force ndb to use v1 of the model by re-loading it.
        reload(models_v1)

        # Save some example data.
        ndb.put_multi([
            models_v1.Picture(author='Alice', name='Sunset'),
            models_v1.Picture(author='Bob', name='Sunrise')
        ])

        self.response.write("""
        Entities created. <a href="/">View entities</a>.
        """)
コード例 #2
0
def test_update_schema(app, testbed):
    reload(models_v1)
    test_model = models_v1.Picture(author='Test', name='Test')
    test_model.put()

    response = app.post('/update_schema')
    assert response.status_int == 200

    # Run the queued task.
    tasks = testbed.taskqueue_stub.get_filtered_tasks()
    assert len(tasks) == 1
    deferred.run(tasks[0].payload)

    # Check the updated items
    reload(models_v2)
    updated_model = test_model.key.get()
    assert updated_model.num_votes == 1
    assert updated_model.avg_rating == 5.0
コード例 #3
0
def test_update_schema(app, testbed):
    reload(models_v1)
    test_model = models_v1.Picture(author='Test', name='Test')
    test_model.put()

    response = app.post('/update_schema')
    if response.status_int != 200:
        raise AssertionError

    # Run the queued task.
    tasks = testbed.taskqueue_stub.get_filtered_tasks()
    if len(tasks) != 1:
        raise AssertionError
    deferred.run(tasks[0].payload)

    # Check the updated items
    reload(models_v2)
    updated_model = test_model.key.get()
    if updated_model.num_votes != 1:
        raise AssertionError
    if updated_model.avg_rating != 5.0:
        raise AssertionError