test_ffdnispdb.py 1007 B

123456789101112131415161718192021222324252627282930313233343536
  1. from ffdnispdb import app, db
  2. from ffdnispdb.models import ISP
  3. from flask import Flask
  4. from flask.ext.sqlalchemy import SQLAlchemy
  5. import unittest
  6. import os
  7. class TestCase(unittest.TestCase):
  8. def setUp(self):
  9. app.config['TESTING'] = True
  10. app.config['WTF_CSRF_ENABLED'] = False
  11. # Ugly, but should work in this context... ?
  12. app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
  13. self.app = app.test_client()
  14. db.create_all()
  15. def tearDown(self):
  16. db.drop_all()
  17. def test_projectform(self):
  18. resp = self.app.post('/create/form', data={
  19. 'name': 'Test',
  20. 'step': '1',
  21. 'covered_areas-0-name': 'Somewhere over the rainbow',
  22. 'covered_areas-0-technologies': 'dsl',
  23. 'covered_areas-0-technologies': 'ftth'
  24. })
  25. self.assertNotEqual(resp.location, None)
  26. self.assertEqual(ISP.query.filter_by(name='Test').count(), 1)
  27. if __name__ == '__main__':
  28. unittest.main()