File: test_migrate_custom_directory.py

package info (click to toggle)
flask-migrate 1.2.0-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 164 kB
  • ctags: 61
  • sloc: python: 246; makefile: 7
file content (39 lines) | stat: -rw-r--r-- 912 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import shutil
from exceptions import OSError
import unittest

class TestMigrate(unittest.TestCase):
    def setUp(self):
        os.chdir(os.path.split(os.path.abspath(__file__))[0])
        try:
            os.remove('app2.db')
        except OSError:
            pass
        try:
            shutil.rmtree('temp_folder')
        except OSError:
            pass

        os.system('python app2.py db init')
        os.system('python app2.py db migrate')
        os.system('python app2.py db upgrade')

    def tearDown(self):
        try:
            os.remove('app2.db')
        except OSError:
            pass
        try:
            shutil.rmtree('migrations')
        except OSError:
            pass

    def test_migrate_upgrade(self):
        from app2 import db, User
        db.session.add(User(name = 'test'))
        db.session.commit()

if __name__ == '__main__':
    unittest.main()