def test_starting_rev_current_pre_context(self): env_file_fixture(""" assert context.get_starting_revision_argument() is None """) assert_raises_message(util.CommandError, "No starting revision argument is available.", command.current, self.cfg)
def test_tag_None(self): env_file_fixture(""" context.configure(dialect_name='sqlite') assert context.get_tag_argument() is None """) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, "%s:%s" % (b, a), sql=True)
def test_tag_cfg_arg(self): env_file_fixture(""" context.configure(dialect_name='sqlite', tag='there') assert context.get_tag_argument() == 'there' """) command.upgrade(self.cfg, b, sql=True, tag='hi') command.downgrade(self.cfg, "%s:%s" % (b, a), sql=True, tag='hi')
def test_destination_rev_pre_context(self): env_file_fixture(""" assert context.get_revision_argument() == '%s' """ % b) command.upgrade(self.cfg, b, sql=True) command.stamp(self.cfg, b, sql=True) command.downgrade(self.cfg, "%s:%s" % (c, b), sql=True)
def test_tag_None(self): env_file_fixture(""" context.configure(dialect_name='sqlite') assert context.get_tag_argument() is None """) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, b, sql=True)
def test_tag_cfg_arg(self): env_file_fixture(""" context.configure(dialect_name='sqlite', tag='there') assert context.get_tag_argument() == 'there' """) command.upgrade(self.cfg, b, sql=True, tag='hi') command.downgrade(self.cfg, b, sql=True, tag='hi')
def test_starting_rev_pre_context_stamp(self): env_file_fixture(""" assert context.get_starting_revision_argument() == 'x' """) assert_raises_message(util.CommandError, "No starting revision argument is available.", command.stamp, self.cfg, a)
def test_destination_rev_pre_context(self): env_file_fixture(""" assert context.get_revision_argument() == '%s' """ % b) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, b, sql=True) command.stamp(self.cfg, b, sql=True)
def test_head_rev_pre_context(self): env_file_fixture(""" assert context.get_head_revision() == '%s' """ % c) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, "%s:%s" % (b, a), sql=True) command.stamp(self.cfg, b, sql=True) command.current(self.cfg)
def test_starting_rev_pre_context_stamp(self): env_file_fixture(""" assert context.get_starting_revision_argument() == 'x' """) assert_raises_message( util.CommandError, "No starting revision argument is available.", command.stamp, self.cfg, a)
def test_head_rev_pre_context(self): env_file_fixture(""" assert context.get_head_revision() == '%s' """ % c) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, b, sql=True) command.stamp(self.cfg, b, sql=True) command.current(self.cfg)
def test_destination_rev_post_context(self): env_file_fixture(""" context.configure(dialect_name='sqlite') assert context.get_revision_argument() == '%s' """ % b) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, b, sql=True) command.stamp(self.cfg, b, sql=True)
def test_destination_rev_post_context(self): env_file_fixture(""" context.configure(dialect_name='sqlite') assert context.get_revision_argument() == '%s' """ % b) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, "%s:%s" % (c, b), sql=True) command.stamp(self.cfg, b, sql=True)
def test_head_rev_post_context(self): env_file_fixture(""" context.configure(dialect_name='sqlite') assert context.get_head_revision() == '%s' """ % c) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, "%s:%s" % (b, a), sql=True) command.stamp(self.cfg, b, sql=True) command.current(self.cfg)
def test_starting_rev_post_context(self): env_file_fixture(""" context.configure(dialect_name='sqlite', starting_rev='x') assert context.get_starting_revision_argument() == 'x' """) command.upgrade(self.cfg, a, sql=True) command.downgrade(self.cfg, a, sql=True) command.current(self.cfg) command.stamp(self.cfg, a)
def test_starting_rev_post_context(self): env_file_fixture(""" context.configure(dialect_name='sqlite', starting_rev='x') assert context.get_starting_revision_argument() == 'x' """) command.upgrade(self.cfg, a, sql=True) command.downgrade(self.cfg, "%s:%s" % (b, a), sql=True) command.current(self.cfg) command.stamp(self.cfg, a)
def test_head_rev_post_context(self): env_file_fixture(""" context.configure(dialect_name='sqlite') assert context.get_head_revision() == '%s' """ % c) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, b, sql=True) command.stamp(self.cfg, b, sql=True) command.current(self.cfg)
def test_starting_rev_current_pre_context(self): env_file_fixture(""" assert context.get_starting_revision_argument() is None """) assert_raises_message( util.CommandError, "No starting revision argument is available.", command.current, self.cfg )
def test_downgrade_wo_colon(self): env_file_fixture(""" context.configure(dialect_name='sqlite') """) assert_raises_message( util.CommandError, "downgrade with --sql requires <fromrev>:<torev>", command.downgrade, self.cfg, b, sql=True )
def test_tmpl_args_revision(self): env_file_fixture(""" context.configure(dialect_name='sqlite', template_args={"somearg":"somevalue"}) """) script_file_fixture(""" # somearg: ${somearg} revision = ${repr(up_revision)} down_revision = ${repr(down_revision)} """) command.revision(self.cfg, message="some rev") script = ScriptDirectory.from_config(self.cfg) rev = script.get_revision('head') text = open(rev.path).read() assert "somearg: somevalue" in text
def test_step_ignore_init_py(self): """test that __init__.py is ignored.""" env_file_fixture(""" context.configure(dialect_name='sqlite', template_args={"somearg":"somevalue"}) """) command.revision(self.cfg, message="some rev") script = ScriptDirectory.from_config(self.cfg) path = os.path.join(script.versions, "__init__.py") with open(path, 'w') as f: f.write( "crap, crap -> crap" ) command.revision(self.cfg, message="another rev") script.get_revision('head')
def test_tag_pre_context_None(self): env_file_fixture(""" assert context.get_tag_argument() is None """) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, b, sql=True)
def test_tag_pre_context(self): env_file_fixture(""" assert context.get_tag_argument() == 'hi' """) command.upgrade(self.cfg, b, sql=True, tag='hi') command.downgrade(self.cfg, b, sql=True, tag='hi')
def test_starting_rev_pre_context(self): env_file_fixture(""" assert context.get_starting_revision_argument() == 'x' """) command.upgrade(self.cfg, "x:y", sql=True) command.downgrade(self.cfg, "x:y", sql=True)
def test_requires_connection(self): env_file_fixture(""" assert context.requires_connection() """) command.upgrade(self.cfg, a) command.downgrade(self.cfg, a)
def test_tag_pre_context(self): env_file_fixture(""" assert context.get_tag_argument() == 'hi' """) command.upgrade(self.cfg, b, sql=True, tag='hi') command.downgrade(self.cfg, "%s:%s" % (b, a), sql=True, tag='hi')
def test_tag_pre_context_None(self): env_file_fixture(""" assert context.get_tag_argument() is None """) command.upgrade(self.cfg, b, sql=True) command.downgrade(self.cfg, "%s:%s" % (b, a), sql=True)
def test_not_requires_connection(self): env_file_fixture(""" assert not context.requires_connection() """) command.upgrade(self.cfg, a, sql=True) command.downgrade(self.cfg, "%s:%s" % (b, a), sql=True)