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)
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
def setUp(self): EnvironmentUtil.setup_fresh_test_env() self.context = CommandContext.via({"type": "memory-db"}) self.newCommand = NewCommand(self.context)
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)
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)