예제 #1
0
 def setUp(self):
     EnvironmentUtil.setup_fresh_test_env()
     self.context = CommandContext.via({'type': 'memory-db'})
     self.downCommand = DownCommand(self.context)
     self.newCommand = NewCommand(self.context)
     self.upCommand = UpCommand(self.context)
     self.checkCommand = CheckCommand(self.context)
예제 #2
0
 def init(cls):
     if not cls.initialized:
         cls.context = CommandContext.via({'type': 'memory-db'})
         cls.newCommand = NewCommand(cls.context)
         cls.upCommand = UpCommand(cls.context)
         cls.initialized = True
예제 #3
0
파일: new.py 프로젝트: jhsu/schema-tool
 def setUp(self):
     EnvironmentUtil.setup_fresh_test_env()
     self.context = CommandContext.via({"type": "memory-db"})
     self.newCommand = NewCommand(self.context)
예제 #4
0
파일: new.py 프로젝트: jhsu/schema-tool
class NewTest(unittest.TestCase):
    def setUp(self):
        EnvironmentUtil.setup_fresh_test_env()
        self.context = CommandContext.via({"type": "memory-db"})
        self.newCommand = NewCommand(self.context)

    def tearDown(self):
        EnvironmentUtil.teardown_fresh_test_env()

    def test_create_down(self):
        sys.argv = make_argv(["-f", "test-file"])
        self.newCommand.run()
        files = os.walk(os.getcwd()).next()[2]
        files = [f for f in files if not f.find("test-file") == -1]
        files = [f for f in files if not f.find("down") == -1]
        self.assertTrue(len(files) == 1)

    def test_create_up(self):
        sys.argv = make_argv(["-f", "test-file"])
        self.newCommand.run()
        files = os.walk(os.getcwd()).next()[2]
        files = [f for f in files if not f.find("test-file") == -1]
        files = [f for f in files if not f.find("up") == -1]
        self.assertTrue(len(files) == 1)

    def test_creates_two_files_on_new(self):
        sys.argv = make_argv(["-f", "test-file"])
        self.newCommand.run()
        files = os.walk(os.getcwd()).next()[2]
        files = [f for f in files if not f.find("test-file") == -1]
        self.assertTrue(len(files) == 2)

    def test_create_files_without_name(self):
        sys.argv = make_argv([])
        self.newCommand.run()
        files = os.walk(os.getcwd()).next()[2]
        files = [f for f in files if not f.find("sql") == -1]
        self.assertTrue(len(files) == 2)

    def test_creates_proper_alter_chain(self):
        sys.argv = make_argv(["-f", "1"])
        self.newCommand.run()
        sleep(0.15)
        sys.argv = make_argv(["-f", "2"])
        self.newCommand.run()

        chain_tail = ChainUtil.build_chain()
        self.assertTrue(chain_tail.backref is not None)
        self.assertTrue(chain_tail.backref.backref is None)

    def test_no_backref_on_single_alter(self):
        sys.argv = make_argv(["-f", "1"])
        self.newCommand.run()

        chain_tail = ChainUtil.build_chain()
        self.assertTrue(chain_tail.backref is None)
예제 #5
0
파일: new.py 프로젝트: zbskii/schema-tool
class NewTest(unittest.TestCase):
    def setUp(self):
        EnvironmentUtil.setup_fresh_test_env()
        self.context = CommandContext.via({'type': 'memory-db'})
        self.newCommand = NewCommand(self.context)

    def tearDown(self):
        EnvironmentUtil.teardown_fresh_test_env()

    def test_create_down(self):
        sys.argv = make_argv(['-f', 'test-file'])
        self.newCommand.run()
        files = os.walk(os.getcwd()).next()[2]
        files = [f for f in files if not f.find('test-file') == -1]
        files = [f for f in files if not f.find('down') == -1]
        self.assertTrue(len(files) == 1)

    def test_create_up(self):
        sys.argv = make_argv(['-f', 'test-file'])
        self.newCommand.run()
        files = os.walk(os.getcwd()).next()[2]
        files = [f for f in files if not f.find('test-file') == -1]
        files = [f for f in files if not f.find('up') == -1]
        self.assertTrue(len(files) == 1)

    def test_creates_two_files_on_new(self):
        sys.argv = make_argv(['-f', 'test-file'])
        self.newCommand.run()
        files = os.walk(os.getcwd()).next()[2]
        files = [f for f in files if not f.find('test-file') == -1]
        self.assertTrue(len(files) == 2)

    def test_create_files_without_name(self):
        sys.argv = make_argv([])
        self.newCommand.run()
        files = os.walk(os.getcwd()).next()[2]
        files = [f for f in files if not f.find('sql') == -1]
        self.assertTrue(len(files) == 2)

    def test_creates_proper_alter_chain(self):
        sys.argv = make_argv(['-f', '1'])
        self.newCommand.run()
        sleep(0.15)
        sys.argv = make_argv(['-f', '2'])
        self.newCommand.run()

        chain_tail = ChainUtil.build_chain()
        self.assertTrue(chain_tail.backref is not None)
        self.assertTrue(chain_tail.backref.backref is None)

    def test_no_backref_on_single_alter(self):
        sys.argv = make_argv(['-f', '1'])
        self.newCommand.run()

        chain_tail = ChainUtil.build_chain()
        self.assertTrue(chain_tail.backref is None)