コード例 #1
0
    def test_serialize(self):

        mig1 = Migration()
        mig1.ID = "0_new_migration"
        mig1.applied_timestamp = time.time()
        ser = mig1.serialize()
        des = Migration.deserialize(ser)

        self.assertEqual(mig1, des)
        self.assertEqual(des.ID, "0_new_migration")
コード例 #2
0
    def test_create_and_read_migration(self):
        mig = Migration()
        mig.ID = "3_my_migration"
        mig.applied_timestamp = time.time()
        self.store.store_executed_migration(mig)

        last = self.store.read_last_migrated()
        self.assertEqual(last, mig)

        mig2 = Migration()
        mig2.ID = "2_my_migration"
        mig2.applied_timestamp = time.time()
        time.sleep(0.05)
        self.store.store_executed_migration(mig2)

        # Its last yet
        last = self.store.read_last_migrated()
        self.assertEqual(last, mig2)

        mig3 = Migration()
        mig3.ID = "4_my_migration"
        mig3.applied_timestamp = time.time()
        time.sleep(0.05)
        self.store.store_executed_migration(mig3)

        last = self.store.read_last_migrated()
        self.assertEqual(last, mig3)

        applied = self.store.applied_migrations()

        self.assertEqual(len(applied), 3)
        self.assertEqual(set(applied), set([mig, mig2, mig3]))
コード例 #3
0
 def applied_migrations(self):
     dbcol = self.db[MigrationStore.collection]
     doc = dbcol.find().sort([(Migration.SERIAL_TIMESTAMP_KEY,
                               pymongo.DESCENDING)])
     mig = [Migration.deserialize(mig) for mig in doc]
     mig.sort()
     return mig
コード例 #4
0
ファイル: migration_store.py プロジェクト: biicode/bii-server
    def read_last_migrated(self):

        dbcol = self.db[MigrationStore.collection]
        doc = dbcol.find().sort([(Migration.SERIAL_TIMESTAMP_KEY, pymongo.DESCENDING)])

        if not doc or doc.count() == 0:
            return None
        else:
            return Migration.deserialize(doc[0])
コード例 #5
0
    def read_last_migrated(self):

        dbcol = self.db[MigrationStore.collection]
        doc = dbcol.find().sort([(Migration.SERIAL_TIMESTAMP_KEY,
                                  pymongo.DESCENDING)])

        if not doc or doc.count() == 0:
            return None
        else:
            return Migration.deserialize(doc[0])
コード例 #6
0
    def test_compare(self):
        mig1 = Migration()
        self.assertEqual(mig1.ID, "Migration")
        mig1.ID = "0_new_migration"
        mig1.applied_timestamp = time.time()
        mig2 = Migration()
        mig2.ID = "1_new_migration"
        mig2.applied_timestamp = mig1.applied_timestamp
        self.assertNotEqual(mig1, mig2)

        self.assertEquals(mig1, mig1)

        mig1_copy = Migration()
        mig1_copy.ID = "0_new_migration"
        mig1_copy.applied_timestamp = mig1.applied_timestamp

        self.assertEquals(mig1, mig1_copy)
コード例 #7
0
    def test_serialize(self):

        mig1 = Migration()
        mig1.ID = "0_new_migration"
        mig1.applied_timestamp = time.time()
        ser = mig1.serialize()
        des = Migration.deserialize(ser)

        self.assertEqual(mig1, des)
        self.assertEqual(des.ID, "0_new_migration")
コード例 #8
0
    def test_compare(self):
        mig1 = Migration()
        self.assertEqual(mig1.ID, "Migration")
        mig1.ID = "0_new_migration"
        mig1.applied_timestamp = time.time()
        mig2 = Migration()
        mig2.ID = "1_new_migration"
        mig2.applied_timestamp = mig1.applied_timestamp
        self.assertNotEqual(mig1, mig2)

        self.assertEquals(mig1, mig1)

        mig1_copy = Migration()
        mig1_copy.ID = "0_new_migration"
        mig1_copy.applied_timestamp = mig1.applied_timestamp

        self.assertEquals(mig1, mig1_copy)
コード例 #9
0
ファイル: migration_store.py プロジェクト: biicode/bii-server
 def applied_migrations(self):
     dbcol = self.db[MigrationStore.collection]
     doc = dbcol.find().sort([(Migration.SERIAL_TIMESTAMP_KEY, pymongo.DESCENDING)])
     mig = [Migration.deserialize(mig) for mig in doc]
     mig.sort()
     return mig