Hi,

personnaly I use request.addfinalizer to rollback the transaction :

https://github.com/CroissanceCommune/autonomie/blob/master/autonomie/tests/conftest.py#L300

Hope this help

Regards

--

Gaston Tjebbes

http://majerti.fr


Le 24/01/2017 à 20:52, Jaime Sangcap a écrit :
> Hi everyone! Im trying to learn python and getting my hands dirty with
> pyramid.
>
> I would really appreciate it if there is anyone willing to give me a
> kickstart on how to do functional test?
> Lets say I posted a data to a url and I want to test that the data has
> been saved to the persistent store or fake store.
> How should I do it?
>
> I have this test class:
>
> class TestCatalogView:
>     def test_it_loads_catalog_add_page(self, testapp):
>         testapp.get('/catalog/add', status=200)
>
>     def test_it_adds_the_course_on_the_catalog(self, testapp):
>         response = testapp.post('/catalog/add', status='30*')
>         assert 'Course has been added' in response.body
>         # here I want to assert that the data has been persisted
>
> the testapp is a fixture with the following details:
>
> @fixture(scope='session')
> def pyramid_test_setup():
>     yield testing.setUp()
>     testing.tearDown()
>
>
> @fixture(scope='session')
> def testapp(pyramid_test_setup):
>     from tgpweb import main
>     from pyramid.paster import get_appsettings
>     settings = get_appsettings('testing.ini', 'main')
>     app = main(global_config=None, **settings)
>     return webtest.TestApp(app)
>
>
> What are the things needed to test this? Im thinking of making a
> Repository Class which uses SqlAlchemy, and another one as Fake
> repository so that in case I dont want to hit a real database I can
> swap the implementation
>
>
> If Im doing it wrong please guide me on how to make it right. maybe I
> have the wrong mindset in testing.
>
>
> Thank you in advance!
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/db009b1b-51c2-493a-809a-2582c6e85d9a%40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/db009b1b-51c2-493a-809a-2582c6e85d9a%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/e43d7678-0e26-082c-ab6f-a9445f223027%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to