Best Python code snippet using tox_python
0019_add_skip_tool_test_table_and_test_install_error_column.py
Source: 0019_add_skip_tool_test_table_and_test_install_error_column.py
1"""2Migration script to add the skip_tool_test table and add the test_install_error column to the repository_metadata table.3"""4import datetime5import logging6import sys7from sqlalchemy import (8 Boolean,9 Column,10 DateTime,11 ForeignKey,12 Integer,13 MetaData,14 Table,15 TEXT,16)17from sqlalchemy.exc import NoSuchTableError18# Need our custom types, but don't import anything else from model19from galaxy.model.custom_types import TrimmedString20log = logging.getLogger(__name__)21log.setLevel(logging.DEBUG)22handler = logging.StreamHandler(sys.stdout)23format = "%(name)s %(levelname)s %(asctime)s %(message)s"24formatter = logging.Formatter(format)25handler.setFormatter(formatter)26log.addHandler(handler)27now = datetime.datetime.utcnow28metadata = MetaData()29SkipToolTest_table = Table(30 "skip_tool_test",31 metadata,32 Column("id", Integer, primary_key=True),33 Column("create_time", DateTime, default=now),34 Column("update_time", DateTime, default=now, onupdate=now),35 Column("repository_metadata_id", Integer, ForeignKey("repository_metadata.id"), index=True),36 Column("initial_changeset_revision", TrimmedString(255), index=True),37 Column("comment", TEXT),38)39def upgrade(migrate_engine):40 print(__doc__)41 metadata.bind = migrate_engine42 metadata.reflect()43 # Initialize.44 if migrate_engine.name == "mysql" or migrate_engine.name == "sqlite":45 default_false = "0"46 elif migrate_engine.name in ["postgresql", "postgres"]:47 default_false = "false"48 try:49 RepositoryMetadata_table = Table("repository_metadata", metadata, autoload=True)50 except NoSuchTableError:51 RepositoryMetadata_table = None52 log.debug("Failed loading table repository_metadata.")53 if RepositoryMetadata_table is not None:54 # Create the test_install_error column.55 c = Column("test_install_error", Boolean, default=False, index=True)56 try:57 c.create(RepositoryMetadata_table, index_name="ix_repository_metadata_ttie")58 assert c is RepositoryMetadata_table.c.test_install_error59 migrate_engine.execute(f"UPDATE repository_metadata SET test_install_error={default_false}")60 except Exception:61 log.exception("Adding test_install_error column to the repository_metadata table failed.")62 # Create skip_tool_test table.63 try:64 SkipToolTest_table.create()65 except Exception:66 log.exception("Creating the skip_tool_test table failed.")67def downgrade(migrate_engine):68 metadata.bind = migrate_engine69 metadata.reflect()70 # Drop the skip_tool_test table.71 try:72 SkipToolTest_table.drop()73 except Exception:74 log.exception("Dropping the skip_tool_test table failed.")75 # Drop test_install_error column from the repository_metadata table.76 RepositoryMetadata_table = Table("repository_metadata", metadata, autoload=True)77 try:78 RepositoryMetadata_table.c.test_install_error.drop()79 except Exception:...
Check out the latest blogs from LambdaTest on this topic:
When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
Selenium, a project hosted by the Apache Software Foundation, is an umbrella open-source project comprising a variety of tools and libraries for test automation. Selenium automation framework enables QA engineers to perform automated web application testing using popular programming languages like Python, Java, JavaScript, C#, Ruby, and PHP.
Are members of agile teams different from members of other teams? Both yes and no. Yes, because some of the behaviors we observe in agile teams are more distinct than in non-agile teams. And no, because we are talking about individuals!
Automation frameworks enable automation testers by simplifying the test development and execution activities. A typical automation framework provides an environment for executing test plans and generating repeatable output. They are specialized tools that assist you in your everyday test automation tasks. Whether it is a test runner, an action recording tool, or a web testing tool, it is there to remove all the hard work from building test scripts and leave you with more time to do quality checks. Test Automation is a proven, cost-effective approach to improving software development. Therefore, choosing the best test automation framework can prove crucial to your test results and QA timeframes.
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!!