Take a look at this step in the SQLAlchemy + URL Dispatch wiki tutorial. http://docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/wiki2/tests.html
--steve On 1/24/17 at 11:52 AM, [email protected] (Jaime Sangcap) pronounced: > 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! > ------------------------ Steve Piercy, Soquel, CA -- 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/r473Ps-10122i-D0A32227364841E787CC254C45A73B69%40Steves-iMac.local. For more options, visit https://groups.google.com/d/optout.
