Esempio n. 1
0
    def test_nonexistent_patch(self):
        """Test case where current patch does not exist"""
        self.conn_handler.execute(
            """UPDATE settings SET current_patch = 'nope.sql'""")
        self._assert_current_patch('nope.sql')

        with self.assertRaises(RuntimeError):
            patch(self.patches_dir)
Esempio n. 2
0
    def test_nonexistent_patch(self):
        """Test case where current patch does not exist"""
        self.conn_handler.execute(
            """UPDATE settings SET current_patch = 'nope.sql'""")
        self._assert_current_patch('nope.sql')

        with self.assertRaises(RuntimeError):
            patch(self.patches_dir)
Esempio n. 3
0
    def test_unpatched(self):
        """Test patching from unpatched state"""
        # Reset the settings table to the unpatched state
        self.conn_handler.execute(
            """UPDATE settings SET current_patch = 'unpatched'""")

        self._assert_current_patch('unpatched')
        patch(self.patches_dir)
        self._check_patchtest2()
        self._check_patchtest10()
        self._assert_current_patch('10.sql')
Esempio n. 4
0
    def test_unpatched(self):
        """Test patching from unpatched state"""
        # Reset the settings table to the unpatched state
        self.conn_handler.execute(
            """UPDATE settings SET current_patch = 'unpatched'""")

        self._assert_current_patch('unpatched')
        patch(self.patches_dir)
        self._check_patchtest2()
        self._check_patchtest10()
        self._assert_current_patch('10.sql')
Esempio n. 5
0
    def test_skip_patch(self):
        """Test patching from a patched state"""
        self.conn_handler.execute(
            """UPDATE settings SET current_patch = '2.sql'""")
        self._assert_current_patch('2.sql')

        # If it tried to apply patch 2.sql again, this will error
        patch(self.patches_dir)

        self._assert_current_patch('10.sql')
        self._check_patchtest10()

        # Since we "tricked" the system, patchtest2 should not exist
        self._check_patchtest2(exists=False)
Esempio n. 6
0
    def test_skip_patch(self):
        """Test patching from a patched state"""
        self.conn_handler.execute(
            """UPDATE settings SET current_patch = '2.sql'""")
        self._assert_current_patch('2.sql')

        # If it tried to apply patch 2.sql again, this will error
        patch(self.patches_dir)

        self._assert_current_patch('10.sql')
        self._check_patchtest10()

        # Since we "tricked" the system, patchtest2 should not exist
        self._check_patchtest2(exists=False)
Esempio n. 7
0
    def test_python_patch(self):
        # Write a test python patch
        patch10_py_fp = join(self.py_patches_dir, '10.py')
        with open(patch10_py_fp, 'w') as f:
            f.write(PY_PATCH)

        # Reset the settings table to the unpatched state
        self.conn_handler.execute(
            """UPDATE settings SET current_patch = 'unpatched'""")

        self._assert_current_patch('unpatched')

        patch(self.patches_dir)

        obs = self.conn_handler.execute_fetchall(
            """SELECT testing FROM qiita.patchtest10""")
        exp = [[1], [100]]
        self.assertEqual(obs, exp)

        self._assert_current_patch('10.sql')
Esempio n. 8
0
    def test_python_patch(self):
        # Write a test python patch
        patch10_py_fp = join(self.py_patches_dir, '10.py')
        with open(patch10_py_fp, 'w') as f:
            f.write(PY_PATCH)

        # Reset the settings table to the unpatched state
        self.conn_handler.execute(
            """UPDATE settings SET current_patch = 'unpatched'""")

        self._assert_current_patch('unpatched')

        patch(self.patches_dir)

        obs = self.conn_handler.execute_fetchall(
            """SELECT testing FROM qiita.patchtest10""")
        exp = [[1], [100]]
        self.assertEqual(obs, exp)

        self._assert_current_patch('10.sql')