Best Python code snippet using tavern
test_dbcommands.py
Source:test_dbcommands.py
...4class MySQLSettingsTest(TestCase):5 def setUp(self):6 self.database = settings.DATABASES['default']7 self.dbsettings = dbcommands.MySQLSettings(self.database)8 def test_get_extension(self):9 extension = self.dbsettings.get_extension()10 # TODO: Can't do below11 # self.assertEqual(app_settings.DBBACKUP_MYSQL_EXTENSION, extension)12 self.assertEqual('mysql', extension)13 def test_get_backup_commands(self):14 wanted_commands = [['mysqldump', '--user={adminuser}',15 '--password={password}', '{databasename}', '>']]16 commands = self.dbsettings.get_backup_commands()17 self.assertEqual(commands, wanted_commands)18 def test_get_restore_commands(self):19 wanted_commands = [['mysql', '--user={adminuser}',20 '--password={password}', '{databasename}', '<']]21 commands = self.dbsettings.get_restore_commands()22 self.assertEqual(commands, wanted_commands)23class PostgreSQLSettingsTest(TestCase):24 def setUp(self):25 self.database = settings.DATABASES['default']26 self.dbsettings = dbcommands.PostgreSQLSettings(self.database)27 def test_get_extension(self):28 extension = self.dbsettings.get_extension()29 self.assertEqual('psql', extension)30 def test_get_backup_commands(self):31 wanted_commands = [['pg_dump', '--username={adminuser}',32 '{databasename}', '>']]33 commands = self.dbsettings.get_backup_commands()34 self.assertEqual(commands, wanted_commands)35 def test_get_restore_commands(self):36 wanted_commands = [37 ['dropdb', '--username={adminuser}', '{databasename}'],38 ['createdb', '--username={adminuser}', '--owner={username}', '{databasename}'],39 ['psql', '-d', '{databasename}', '-f', '-', '--username={adminuser}', '--single-transaction', '<']40 ]41 commands = self.dbsettings.get_restore_commands()42 self.assertEqual(commands, wanted_commands)43class PostgisSQLSettingsTest(PostgreSQLSettingsTest):44 def setUp(self):45 self.database = settings.DATABASES['default']46 self.dbsettings = dbcommands.PostgisSQLSettings(self.database)47 def test_get_restore_commands(self):48 wanted_commands = [49 ['dropdb', '--username={adminuser}', '{databasename}'],50 ['createdb', '--username={adminuser}', '--owner={username}', '{databasename}'],51 ['psql', '--username={adminuser}', '-c', 'CREATE EXTENSION postgis;', '{databasename}'],52 ['psql', '-d', '{databasename}', '-f', '-', '--username={adminuser}', '--single-transaction', '<']53 ]54 commands = self.dbsettings.get_restore_commands()55 self.assertEqual(commands, wanted_commands)56class SQLiteSettingsTest(TestCase):57 def setUp(self):58 self.database = settings.DATABASES['default']59 self.dbsettings = dbcommands.SQLiteSettings(self.database)60 def test_get_extension(self):61 extension = self.dbsettings.get_extension()62 self.assertEqual('sqlite', extension)63 def test_get_backup_commands(self):64 wanted_commands = [['<READ_FILE>', '{databasename}']]65 commands = self.dbsettings.get_backup_commands()66 self.assertEqual(commands, wanted_commands)67 def test_get_get_restore_commands(self):68 wanted_commands = [['<WRITE_FILE>', '{databasename}']]69 commands = self.dbsettings.get_restore_commands()...
test_filesystem.py
Source:test_filesystem.py
1from tests import TestCase2from src.masonite.utils.filesystem import get_extension3class TestFileUtils(TestCase):4 def test_get_extension(self):5 self.assertEqual(get_extension("log.txt"), ".txt")6 self.assertEqual(get_extension("archive.tar.gz"), ".tar.gz")7 self.assertEqual(get_extension("path/to/log.txt"), ".txt")8 self.assertEqual(get_extension("log.txt", without_dot=True), "txt")...
test_utils.py
Source:test_utils.py
...10 (Path("file.tar.gz"), ".gz"),11 (Path("dir/"), ""),12 ],13)14def test_get_extension(path, expected):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!