def test_migrateAddressbookFromFile(self): """ C{_migrateAddressbook()} can migrate a file-backed addressbook to a database- backed addressbook. """ fromAddressbook = yield self.fileTransaction().addressbookHomeWithUID( "home1").addressbookWithName("addressbook") toHome = yield self.transactionUnderTest().addressbookHomeWithUID( "new-home", create=True) toAddressbook = yield toHome.addressbookWithName("addressbook") yield _migrateAddressbook(fromAddressbook, toAddressbook, lambda x: x.component()) yield self.assertAddressbooksSimilar(fromAddressbook, toAddressbook)
def test_migrateBadAddressbookFromFile(self): """ C{_migrateAddressbook()} can migrate a file-backed addressbook to a database-backed addressbook. We need to test what happens when there is "bad" address data present in the file-backed addressbook. """ fromAddressbook = yield self.fileTransaction().addressbookHomeWithUID( "home_bad").addressbookWithName("addressbook") toHome = yield self.transactionUnderTest().addressbookHomeWithUID( "new-home", create=True) toAddressbook = yield toHome.addressbookWithName("addressbook") ok, bad = (yield _migrateAddressbook(fromAddressbook, toAddressbook, lambda x: x.component())) self.assertEqual(ok, 1) self.assertEqual(bad, 1)