"Fossies" - the Fresh Open Source Software Archive

Member "buildbot-2.5.1/buildbot/test/unit/test_db_migrate_versions_042_add_build_properties_table.py" (24 Nov 2019, 1893 Bytes) of package /linux/misc/buildbot-2.5.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # This file is part of Buildbot.  Buildbot is free software: you can
    2 # redistribute it and/or modify it under the terms of the GNU General Public
    3 # License as published by the Free Software Foundation, version 2.
    4 #
    5 # This program is distributed in the hope that it will be useful, but WITHOUT
    6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    7 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    8 # details.
    9 #
   10 # You should have received a copy of the GNU General Public License along with
   11 # this program; if not, write to the Free Software Foundation, Inc., 51
   12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   13 #
   14 # Copyright Buildbot Team Members
   15 
   16 import sqlalchemy as sa
   17 
   18 from twisted.trial import unittest
   19 
   20 from buildbot.test.util import migration
   21 from buildbot.util import sautils
   22 
   23 
   24 class Migration(migration.MigrateTestMixin, unittest.TestCase):
   25 
   26     def setUp(self):
   27         return self.setUpMigrateTest()
   28 
   29     def tearDown(self):
   30         return self.tearDownMigrateTest()
   31 
   32     def test_migration(self):
   33         def setup_thd(conn):
   34             metadata = sa.MetaData()
   35             metadata.bind = conn
   36 
   37             sautils.Table(
   38                 'builds', metadata,
   39                 sa.Column('id', sa.Integer, primary_key=True),
   40                 # ..
   41             ).create()
   42 
   43         def verify_thd(conn):
   44             metadata = sa.MetaData()
   45             metadata.bind = conn
   46 
   47             build_properties = sautils.Table(
   48                 'build_properties', metadata, autoload=True)
   49 
   50             q = sa.select([build_properties.c.buildid,
   51                            build_properties.c.name,
   52                            build_properties.c.value,
   53                            build_properties.c.source])
   54             self.assertEqual(conn.execute(q).fetchall(), [])
   55 
   56         return self.do_test_migration(41, 42, setup_thd, verify_thd)