コード例 #1
0
ファイル: cqlexecutor_test.py プロジェクト: y0sh33/cdeploy
 def test_it_creates_the_table_if_not_existing(self):
     CQLExecutor.init_table(self.session)
     self.session.execute.assert_called_once_with("""
         CREATE TABLE IF NOT EXISTS schema_migrations
                 (type text, version int, PRIMARY KEY(type, version))
             WITH COMMENT = 'Schema migration history'
             AND CLUSTERING ORDER BY (version DESC)
     """)
コード例 #2
0
ファイル: cqlexecutor_test.py プロジェクト: y0sh33/cdeploy
 def test_it_multi_line_statements(self):
     CQLExecutor.execute(
         self.session,
         'statement start\nmore statement\nend statement;\nstatement\n2')
     self.session.execute.assert_has_calls([
         mock.call('statement start more statement end statement'),
         mock.call('statement 2')
     ])
コード例 #3
0
 def test_it_creates_the_table_if_not_existing(self):
     CQLExecutor.init_table(self.session)
     self.session.execute.assert_called_once_with("""
         CREATE TABLE IF NOT EXISTS schema_migrations
                 (type text, version int, PRIMARY KEY(type, version))
             WITH COMMENT = 'Schema migration history'
             AND CLUSTERING ORDER BY (version DESC)
     """)
コード例 #4
0
ファイル: cqlexecutor_test.py プロジェクト: y0sh33/cdeploy
 def test_it_removes_the_most_recent_schema_migration_row(self):
     CQLExecutor.get_top_version = mock.Mock(
         return_value=[mock.Mock(version=5)])
     CQLExecutor.rollback_schema_migration(self.session)
     self.session.execute.assert_called_once_with("""
         DELETE FROM schema_migrations
             WHERE type = 'migration'
                 AND version = 5""")
コード例 #5
0
 def test_it_ignores_comments(self):
     CQLExecutor.execute(
         self.session,
         'line1;\n--comment\n//comment\n\t//comment\nline2'
     )
     self.session.execute.assert_has_calls([
         mock.call('line1'),
         mock.call('line2')
     ])
コード例 #6
0
 def test_it_multi_line_statements(self):
     CQLExecutor.execute(
         self.session,
         'statement start\nmore statement\nend statement;\nstatement\n2'
     )
     self.session.execute.assert_has_calls([
         mock.call('statement start more statement end statement'),
         mock.call('statement 2')
     ])
コード例 #7
0
 def test_it_removes_the_most_recent_schema_migration_row(self):
     CQLExecutor.get_top_version = mock.Mock(
         return_value=[mock.Mock(version=5)]
     )
     CQLExecutor.rollback_schema_migration(self.session)
     self.session.execute.assert_called_once_with("""
         DELETE FROM schema_migrations
             WHERE type = 'migration'
                 AND version = 5""")
コード例 #8
0
    def test_it_selects_the_most_recent_migration(self):
        row = []
        self.session.execute = Mock(return_value=row)

        result = CQLExecutor.get_top_version(self.session)

        self.assertEquals(row, result)
        self.session.execute.assert_called_once_with('SELECT * FROM schema_migrations LIMIT 1')
コード例 #9
0
ファイル: cqlexecutor_test.py プロジェクト: y0sh33/cdeploy
 def test_it_ignores_whitespace_and_other_text_following_undo_marker(self):
     CQLExecutor.execute_undo(
         self.session,
         'migration statement;\n\t--//@UNDO  begin undo\nundo statement')
     self.session.execute.assert_called_once_with('undo statement')
コード例 #10
0
ファイル: cqlexecutor_test.py プロジェクト: y0sh33/cdeploy
 def test_it_runs_the_undo_section(self):
     CQLExecutor.execute_undo(
         self.session, 'migration statement;\n--//@UNDO\nundo statement')
     self.session.execute.assert_called_once_with('undo statement')
コード例 #11
0
ファイル: cqlexecutor_test.py プロジェクト: y0sh33/cdeploy
 def test_it_ignores_comments(self):
     CQLExecutor.execute(
         self.session, 'line1;\n--comment\n//comment\n\t//comment\nline2')
     self.session.execute.assert_has_calls(
         [mock.call('line1'), mock.call('line2')])
コード例 #12
0
ファイル: cqlexecutor_test.py プロジェクト: y0sh33/cdeploy
 def test_it_updates_schema_migrations_with_the_migration_version(self):
     CQLExecutor.add_schema_migration(self.session, 10)
     self.session.execute.assert_called_once_with("""
         INSERT INTO schema_migrations (type, version)
             VALUES ('migration', 10)""")
コード例 #13
0
ファイル: cqlexecutor_test.py プロジェクト: y0sh33/cdeploy
 def test_it_executes_a_multi_line_migration_script(self):
     CQLExecutor.execute(self.session, 'line1;\nline2;\n')
     self.session.execute.assert_has_calls(
         [mock.call('line1'), mock.call('line2')])
コード例 #14
0
 def test_it_executes_the_migration_script(self):
     CQLExecutor.execute(self.session, 'script')
     self.session.execute.assert_called_once_with('script')
コード例 #15
0
ファイル: cqlexecutor_test.py プロジェクト: y0sh33/cdeploy
 def test_it_executes_the_migration_script(self):
     CQLExecutor.execute(self.session, 'script')
     self.session.execute.assert_called_once_with('script')
コード例 #16
0
 def test_it_executes_a_multi_line_migration_script(self):
     CQLExecutor.execute(self.session, 'line1;\nline2;\n')
     self.session.execute.assert_has_calls(
         [mock.call('line1'), mock.call('line2')]
     )
コード例 #17
0
 def test_it_updates_schema_migrations_with_the_migration_version(self):
     CQLExecutor.add_schema_migration(self.session, 10)
     self.session.execute.assert_called_once_with("""
         INSERT INTO schema_migrations (type, version)
             VALUES ('migration', 10)""")
コード例 #18
0
 def test_it_runs_the_undo_section(self):
     CQLExecutor.execute_undo(
         self.session,
         'migration statement;\n--//@UNDO\nundo statement')
     self.session.execute.assert_called_once_with('undo statement')
コード例 #19
0
 def test_it_ignores_whitespace_and_other_text_following_undo_marker(self):
     CQLExecutor.execute_undo(
         self.session,
         'migration statement;\n\t--//@UNDO  begin undo\nundo statement')
     self.session.execute.assert_called_once_with('undo statement')