Le repo des sources pour le site web des JM2L
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

33 lines
883 B

  1. import unittest
  2. import transaction
  3. from pyramid import testing
  4. from .models import DBSession
  5. class TestMyView(unittest.TestCase):
  6. def setUp(self):
  7. self.config = testing.setUp()
  8. from sqlalchemy import create_engine
  9. engine = create_engine('sqlite://')
  10. from .models import (
  11. Base,
  12. MyModel,
  13. )
  14. DBSession.configure(bind=engine)
  15. Base.metadata.create_all(engine)
  16. with transaction.manager:
  17. model = MyModel(name='one', value=55)
  18. DBSession.add(model)
  19. def tearDown(self):
  20. DBSession.remove()
  21. testing.tearDown()
  22. def test_it(self):
  23. from .views import my_view
  24. request = testing.DummyRequest()
  25. info = my_view(request)
  26. self.assertEqual(info['one'].name, 'one')
  27. self.assertEqual(info['project'], 'pyramid_blogr')