Ejemplo n.º 1
0
 def test_multiple_migrations(self):
     self.settings['directory'] = os.path.join(os.path.dirname(__file__),
                                               'fixtures', 'initial')
     mariposa = DBMigrate(**self.settings)
     mariposa.migrate()
     mariposa.directory = os.path.join(os.path.dirname(__file__),
                                       'fixtures', 'second-run')
     mariposa.migrate()
     self.assertEqual(mariposa.engine.performed_migrations(),
                      [('20120115075349-create-user-table.sql',
                        '0187aa5e13e268fc621c894a7ac4345579cf50b7'),
                       ('20120603133552-awesome.sql',
                        '6759512e1e29b60a82b4a5587c5ea18e06b7d381')])
Ejemplo n.º 2
0
 def test_multiple_migrations(self):
     self.settings['directory'] = os.path.join(
         os.path.dirname(__file__), 'fixtures', 'initial')
     mariposa = DBMigrate(**self.settings)
     mariposa.migrate()
     mariposa.directory = os.path.join(
         os.path.dirname(__file__), 'fixtures', 'second-run')
     mariposa.migrate()
     self.assertEqual(
         mariposa.engine.performed_migrations(),
         [('20120115075349-create-user-table.sql',
           '0187aa5e13e268fc621c894a7ac4345579cf50b7'),
          ('20120603133552-awesome.sql',
           '6759512e1e29b60a82b4a5587c5ea18e06b7d381')])
Ejemplo n.º 3
0
 def test_ignore_filenames_sha1_migration(self):
     self.settings['directory'] = os.path.join(os.path.dirname(__file__),
                                               'fixtures', 'sha1-update-1')
     mariposa = DBMigrate(**self.settings)
     mariposa.migrate()
     mariposa.directory = os.path.join(os.path.dirname(__file__),
                                       'fixtures', 'sha1-update-2')
     mariposa.renamed()
     mariposa.migrate()
     self.assertEqual(
         mariposa.engine.performed_migrations(),
         [('20120115075300-add-another-test-table-renamed-reordered.sql',
           '4aebd2514665effff5105ad568a4fbe62f567087'),
          ('20120115075349-create-user-table.sql',
           '0187aa5e13e268fc621c894a7ac4345579cf50b7')])
Ejemplo n.º 4
0
 def test_deleted_migrations_detected(self):
     fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures',
                                  'deleted-1')
     self.settings['directory'] = fixtures_path
     mariposa = DBMigrate(**self.settings)
     mariposa.migrate()
     mariposa.directory = os.path.join(os.path.dirname(__file__),
                                       'fixtures', 'deleted-2')
     try:
         mariposa.migrate()
         self.fail('Expected a ModifiedMigrationException')
     except ModifiedMigrationException as e:
         self.assertEqual(str(e),
                          ('[20120115221757-initial.sql] migrations were '
                           'deleted since they were run on this database.'))
Ejemplo n.º 5
0
 def test_allowed_out_of_order_migration(self):
     fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures',
                                  'out-of-order-1')
     self.settings['directory'] = fixtures_path
     self.settings['out_of_order'] = True
     mariposa = DBMigrate(**self.settings)
     mariposa.migrate()
     mariposa.directory = os.path.join(os.path.dirname(__file__),
                                       'fixtures', 'out-of-order-2')
     mariposa.migrate()
     self.assertEqual(mariposa.engine.performed_migrations(),
                      [('20120114221757-before-initial.sql',
                        'c7fc17564f24f7b960e9ef3f6f9130203cc87dc9'),
                       ('20120115221757-initial.sql',
                        '841ea60d649264965a3e8c8a955fd7aad54dad3e')])
Ejemplo n.º 6
0
 def test_out_of_order_migration(self):
     fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures',
                                  'out-of-order-1')
     self.settings['directory'] = fixtures_path
     mariposa = DBMigrate(**self.settings)
     mariposa.migrate()
     mariposa.directory = os.path.join(os.path.dirname(__file__),
                                       'fixtures', 'out-of-order-2')
     try:
         mariposa.migrate()
         self.fail('Expected an OutOfOrder exception')
     except OutOfOrderException as e:
         self.assertEqual(str(e),
                          ('[20120114221757-before-initial.sql] '
                           'older than the latest performed migration'))
Ejemplo n.º 7
0
 def test_ignore_filenames_sha1_migration(self):
     self.settings['directory'] = os.path.join(
         os.path.dirname(__file__), 'fixtures', 'sha1-update-1')
     mariposa = DBMigrate(**self.settings)
     mariposa.migrate()
     mariposa.directory = os.path.join(
         os.path.dirname(__file__), 'fixtures', 'sha1-update-2')
     mariposa.renamed()
     mariposa.migrate()
     self.assertEqual(
         mariposa.engine.performed_migrations(),
         [('20120115075300-add-another-test-table-renamed-reordered.sql',
           '4aebd2514665effff5105ad568a4fbe62f567087'),
          ('20120115075349-create-user-table.sql',
           '0187aa5e13e268fc621c894a7ac4345579cf50b7')])
Ejemplo n.º 8
0
 def test_deleted_migrations_detected(self):
     fixtures_path = os.path.join(
         os.path.dirname(__file__), 'fixtures', 'deleted-1')
     self.settings['directory'] = fixtures_path
     mariposa = DBMigrate(**self.settings)
     mariposa.migrate()
     mariposa.directory = os.path.join(
         os.path.dirname(__file__), 'fixtures', 'deleted-2')
     try:
         mariposa.migrate()
         self.fail('Expected a ModifiedMigrationException')
     except ModifiedMigrationException as e:
         self.assertEqual(
             str(e),
             ('[20120115221757-initial.sql] migrations were '
              'deleted since they were run on this database.'))
Ejemplo n.º 9
0
 def test_allowed_out_of_order_migration(self):
     fixtures_path = os.path.join(
         os.path.dirname(__file__), 'fixtures', 'out-of-order-1')
     self.settings['directory'] = fixtures_path
     self.settings['out_of_order'] = True
     mariposa = DBMigrate(**self.settings)
     mariposa.migrate()
     mariposa.directory = os.path.join(
         os.path.dirname(__file__), 'fixtures', 'out-of-order-2')
     mariposa.migrate()
     self.assertEqual(
         mariposa.engine.performed_migrations(),
         [('20120114221757-before-initial.sql',
           'c7fc17564f24f7b960e9ef3f6f9130203cc87dc9'),
          ('20120115221757-initial.sql',
           '841ea60d649264965a3e8c8a955fd7aad54dad3e')])
Ejemplo n.º 10
0
 def test_out_of_order_migration(self):
     fixtures_path = os.path.join(
         os.path.dirname(__file__), 'fixtures', 'out-of-order-1')
     self.settings['directory'] = fixtures_path
     mariposa = DBMigrate(**self.settings)
     mariposa.migrate()
     mariposa.directory = os.path.join(
         os.path.dirname(__file__), 'fixtures', 'out-of-order-2')
     try:
         mariposa.migrate()
         self.fail('Expected an OutOfOrder exception')
     except OutOfOrderException as e:
         self.assertEqual(
             str(e),
             ('[20120114221757-before-initial.sql] '
              'older than the latest performed migration'))