test_example.py 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # -*- coding: utf-8 -*-
  2. # TODO - G.M - [Cleanup][tempExample] Drop this file
  3. # import unittest
  4. # import transaction
  5. #
  6. # from pyramid import testing
  7. #
  8. #
  9. # def dummy_request(dbsession):
  10. # return testing.DummyRequest(dbsession=dbsession)
  11. #
  12. #
  13. # class BaseTest(unittest.TestCase):
  14. # def setUp(self):
  15. # self.config = testing.setUp(settings={
  16. # 'sqlalchemy.url': 'sqlite:///:memory:'
  17. # })
  18. # self.config.include('tracim.models')
  19. # settings = self.config.get_settings()
  20. #
  21. # from tracim.models import (
  22. # get_engine,
  23. # get_session_factory,
  24. # get_tm_session,
  25. # )
  26. #
  27. # self.engine = get_engine(settings)
  28. # session_factory = get_session_factory(self.engine)
  29. #
  30. # self.session = get_tm_session(session_factory, transaction.manager)
  31. #
  32. # def init_database(self):
  33. # from tracim.models.meta import DeclarativeBase
  34. # DeclarativeBase.metadata.create_all(self.engine)
  35. #
  36. # def tearDown(self):
  37. # from tracim.models.meta import DeclarativeBase
  38. #
  39. # testing.tearDown()
  40. # transaction.abort()
  41. # DeclarativeBase.metadata.drop_all(self.engine)
  42. #
  43. #
  44. # class TestMyViewSuccessCondition(BaseTest):
  45. #
  46. # def setUp(self):
  47. # super(TestMyViewSuccessCondition, self).setUp()
  48. # self.init_database()
  49. #
  50. # from tracim.models import MyModel
  51. #
  52. # model = MyModel(name='one', value=55)
  53. # self.session.add(model)
  54. #
  55. # def test_passing_view(self):
  56. # from tracim.views.default import my_view
  57. # info = my_view(dummy_request(self.session))
  58. # self.assertEqual(info['one'].name, 'one')
  59. # self.assertEqual(info['project'], 'tracim')
  60. #
  61. #
  62. # class TestMyViewFailureCondition(BaseTest):
  63. #
  64. # def test_failing_view(self):
  65. # from tracim.views.default import my_view
  66. # info = my_view(dummy_request(self.session))
  67. # self.assertEqual(info.status_int, 500)