How to use clear_migrations_done method in autotest

Best Python code snippet using autotest_python

migrate_unittest.py

Source: migrate_unittest.py Github

copy

Full Screen

...20 @classmethod21 def get_migrations_done(cls):22 return cls.migrations_done23 @classmethod24 def clear_migrations_done(cls):25 cls.migrations_done = []26 @classmethod27 def do_migration(cls, version, direction):28 cls.migrations_done.append((version, direction))29 def migrate_up(self, manager):30 self.do_migration(self.version, 'up')31 if self.version == 1:32 manager.create_migrate_table()33 def migrate_down(self, manager):34 self.do_migration(self.version, 'down')35MIGRATIONS = [DummyMigration(n) for n in xrange(1, NUM_MIGRATIONS + 1)]36class TestableMigrationManager(migrate.MigrationManager):37 def _set_migrations_dir(self, migrations_dir=None):38 pass39 def get_migrations(self, minimum_version=None, maximum_version=None):40 minimum_version = minimum_version or 141 maximum_version = maximum_version or len(MIGRATIONS)42 return MIGRATIONS[minimum_version-1:maximum_version]43class MigrateManagerTest(unittest.TestCase):44 def setUp(self):45 self._database = (46 database_connection.DatabaseConnection.get_test_database())47 self._database.connect()48 self.manager = TestableMigrationManager(self._database)49 DummyMigration.clear_migrations_done()50 def tearDown(self):51 self._database.disconnect()52 def test_sync(self):53 self.manager.do_sync_db()54 self.assertEquals(self.manager.get_db_version(), NUM_MIGRATIONS)55 self.assertEquals(DummyMigration.get_migrations_done(),56 [(1, 'up'), (2, 'up'), (3, 'up')])57 DummyMigration.clear_migrations_done()58 self.manager.do_sync_db(0)59 self.assertEquals(self.manager.get_db_version(), 0)60 self.assertEquals(DummyMigration.get_migrations_done(),61 [(3, 'down'), (2, 'down'), (1, 'down')])62 def test_sync_one_by_one(self):63 for version in xrange(1, NUM_MIGRATIONS + 1):64 self.manager.do_sync_db(version)65 self.assertEquals(self.manager.get_db_version(),66 version)67 self.assertEquals(68 DummyMigration.get_migrations_done()[-1],69 (version, 'up'))70 for version in xrange(NUM_MIGRATIONS - 1, -1, -1):71 self.manager.do_sync_db(version)72 self.assertEquals(self.manager.get_db_version(),73 version)74 self.assertEquals(75 DummyMigration.get_migrations_done()[-1],76 (version + 1, 'down'))77 def test_null_sync(self):78 self.manager.do_sync_db()79 DummyMigration.clear_migrations_done()80 self.manager.do_sync_db()81 self.assertEquals(DummyMigration.get_migrations_done(), [])82class DummyMigrationManager(object):83 def __init__(self):84 self.calls = []85 def execute_script(self, script):86 self.calls.append(script)87class MigrationTest(unittest.TestCase):88 def setUp(self):89 self.manager = DummyMigrationManager()90 def _do_migration(self, migration_module):91 migration = migrate.Migration('name', 1, migration_module)92 migration.migrate_up(self.manager)93 migration.migrate_down(self.manager)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

QA Innovation – Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Why Agile Is Great for Your Business

Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.

LIVE With Automation Testing For OTT Streaming Devices ????

People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.

Difference Between Web And Mobile Application Testing

Smartphones have changed the way humans interact with technology. Be it travel, fitness, lifestyle, video games, or even services, it’s all just a few touches away (quite literally so). We only need to look at the growing throngs of smartphone or tablet users vs. desktop users to grasp this reality.

How To Handle Multiple Windows In Selenium Python

Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful