def test_full(self): """ Running C{calendarserver_export} on the command line exports an ics file. (Almost-full integration test, starting from the main point, using as few test fakes as possible.) Note: currently the only test for directory interaction. """ yield populateCalendarsFrom( { "user02": { # TODO: more direct test for skipping inbox "inbox": { "inbox-item.ics": (valentines, {}) }, "calendar1": { "peruser.ics": (dataForTwoUsers, {}), # EST } } }, self.store) output = FilePath(self.mktemp()) main([ 'calendarserver_export', '--output', output.path, '--user', 'user02' ], reactor=self) yield self.waitToStop self.assertEquals(Component.fromString(resultForUser2), Component.fromString(output.getContent()))
def test_full(self): """ Running C{calendarserver_export} on the command line exports an ics file. (Almost-full integration test, starting from the main point, using as few test fakes as possible.) Note: currently the only test for directory interaction. """ yield populateCalendarsFrom( { "user02": { # TODO: more direct test for skipping inbox "inbox": { "inbox-item.ics": (valentines, {}) }, "calendar1": { "peruser.ics": (dataForTwoUsers, {}), # EST } } }, self.store ) output = FilePath(self.mktemp()) main(['calendarserver_export', '--output', output.path, '--user', 'user02'], reactor=self) yield self.waitToStop self.assertEquals( Component.fromString(resultForUser2), Component.fromString(output.getContent()) )
def test_exportAllContacts(self): """ Run the export with --all --contacts to get a directory of addressbooks from all addressbook homes in the database. """ yield populateAddressBooksFrom( { "user01": { "addressbook": { "1.vcf": adbk1Root.child("1.vcf").getContent(), "2.vcf": adbk1Root.child("2.vcf").getContent(), "3.vcf": adbk1Root.child("3.vcf").getContent(), } }, "user02": { "addressbook": { "1.vcf": adbk1Root.child("1.vcf").getContent(), }, } }, self.store) outputDir = FilePath(self.mktemp()) outputDir.makedirs() main([ 'calendarserver_export', '--directory', outputDir.path, '--all', '--contacts' ], reactor=self) yield self.waitToStop self.assertEquals( set(["user01_addressbook.vcf", "user02_addressbook.vcf"]), set([child.basename() for child in outputDir.children()]))
def test_exportOneAddressbook(self): """ Run the export with a single uid and --contacts """ yield populateAddressBooksFrom( { "user01": { "addressbook": { "1.vcf": adbk1Root.child("1.vcf").getContent(), "2.vcf": adbk1Root.child("2.vcf").getContent(), "3.vcf": adbk1Root.child("3.vcf").getContent(), } }, "user02": { "addressbook": { "1.vcf": adbk1Root.child("1.vcf").getContent(), }, } }, self.store) outputDir = FilePath(self.mktemp()) outputDir.makedirs() main([ 'calendarserver_export', '--directory', outputDir.path, '--uid', 'user01', '--contacts' ], reactor=self) yield self.waitToStop self.assertEquals( set(["user01_addressbook.vcf"]), set([child.basename() for child in outputDir.children()]))
def test_exportAll(self): """ Run the export with --all to get a directory of calendars from all calendar homes in the database. """ yield populateCalendarsFrom( { "user01": { "calendar1": { "valentines-day.ics": (valentines, {}), "new-years-day.ics": (newYears, {}) } }, "user02": { "calendar1": { "valentines-day.ics": (valentines, {}) }, "calendar2": { "new-years-day.ics": (newYears, {}) } } }, self.store) outputDir = FilePath(self.mktemp()) outputDir.makedirs() main([ 'calendarserver_export', '--directory', outputDir.path, '--all' ], reactor=self) yield self.waitToStop self.assertEquals( set([ "user01_calendar1.ics", "user02_calendar1.ics", "user02_calendar2.ics" ]), set([child.basename() for child in outputDir.children()]))
def test_full(self): """ Running C{calendarserver_export} on the command line exports an ics file. (Almost-full integration test, starting from the main point, using as few test fakes as possible.) Note: currently the only test for directory interaction. """ yield populateCalendarsFrom( { "user02": { # TODO: more direct test for skipping inbox "inbox": { "inbox-item.ics": (valentines, {}) }, "calendar1": { "peruser.ics": (dataForTwoUsers, {}), # EST } } }, self.store ) augmentsData = """ <augments> <record> <uid>Default</uid> <enable>true</enable> <enable-calendar>true</enable-calendar> <enable-addressbook>true</enable-addressbook> </record> </augments> """ augments = FilePath(self.mktemp()) augments.setContent(augmentsData) accountsData = """ <accounts realm="Test Realm"> <user> <uid>user-under-test</uid> <guid>user02</guid> <name>Not Interesting</name> <password>very-secret</password> </user> </accounts> """ accounts = FilePath(self.mktemp()) accounts.setContent(accountsData) output = FilePath(self.mktemp()) self.accountsFile = accounts.path self.augmentsFile = augments.path main(['calendarserver_export', '--output', output.path, '--user', 'user-under-test'], reactor=self) yield self.waitToStop self.assertEquals( Component.fromString(resultForUser2), Component.fromString(output.getContent()) )
def test_serviceState(self): """ export.main() invokes utilityMain with the configuration file specified on the command line, and creates an L{ExporterService} pointed at the appropriate store. """ tempConfig = self.mktemp() main(['calendarserver_export', '--config', tempConfig, '--output', self.mktemp()], reactor=self) self.assertEquals(self.mainCalled, True, "Main not called.") self.assertEquals(self.usedConfigFile, tempConfig) self.assertEquals(self.usedReactor, self) self.assertEquals(self.exportService.store, self.store) yield self.waitToStop
def test_serviceState(self): """ export.main() invokes utilityMain with the configuration file specified on the command line, and creates an L{ExporterService} pointed at the appropriate store. """ tempConfig = self.mktemp() main(['calendarserver_export', '--config', tempConfig, '--output', self.mktemp()], reactor=self) self.assertEquals(self.mainCalled, True, "Main not called.") self.assertEquals(self.usedConfigFile, tempConfig) self.assertEquals(self.usedReactor, self) self.assertEquals(self.exportService.store, self.store) yield self.waitToStop
def test_exportMixAndMatch(self): """ Run the export with some calendars and some addressbooks """ yield populateAddressBooksFrom( { "user01": { "addressbook": { "1.vcf": adbk1Root.child("1.vcf").getContent(), "2.vcf": adbk1Root.child("2.vcf").getContent(), "3.vcf": adbk1Root.child("3.vcf").getContent(), } }, "user02": { "addressbook": { "1.vcf": adbk1Root.child("1.vcf").getContent(), }, } }, self.store) yield populateCalendarsFrom( { "user01": { "calendar1": { "valentines-day.ics": (valentines, {}), "new-years-day.ics": (newYears, {}) } }, "user02": { "calendar1": { "valentines-day.ics": (valentines, {}) }, "calendar2": { "new-years-day.ics": (newYears, {}) } } }, self.store) outputDir = FilePath(self.mktemp()) outputDir.makedirs() main([ 'calendarserver_export', '--directory', outputDir.path, '--uid', 'user01', '--contacts', '--uid', 'user01', '--calendars', '--uid', 'user02', '--collection=calendar1', '--uid', 'user02', '--contacts', ], reactor=self) yield self.waitToStop self.assertEquals( set([ "user01_addressbook.vcf", "user01_calendar1.ics", "user02_calendar1.ics", "user02_addressbook.vcf" ]), set([child.basename() for child in outputDir.children()]))
def test_full(self): """ Running C{calendarserver_export} on the command line exports an ics file. (Almost-full integration test, starting from the main point, using as few test fakes as possible.) Note: currently the only test for directory interaction. """ yield populateCalendarsFrom( { "user02": { # TODO: more direct test for skipping inbox "inbox": { "inbox-item.ics": (valentines, {}) }, "calendar1": { "peruser.ics": (dataForTwoUsers, {}), # EST } } }, self.store) output = FilePath(self.mktemp()) main([ 'calendarserver_export', '--output', output.path, '--user', 'user02' ], reactor=self) yield self.waitToStop self.assertEquals(Component.fromString(resultForUser2), Component.fromString(output.getContent())) @inlineCallbacks def test_exportAll(self): """ Run the export with --all to get a directory of calendars from all calendar homes in the database. """ yield populateCalendarsFrom( { "user01": { "calendar1": { "valentines-day.ics": (valentines, {}), "new-years-day.ics": (newYears, {}) } }, "user02": { "calendar1": { "valentines-day.ics": (valentines, {}) }, "calendar2": { "new-years-day.ics": (newYears, {}) } } }, self.store) outputDir = FilePath(self.mktemp()) outputDir.makedirs() main([ 'calendarserver_export', '--directory', outputDir.path, '--all' ], reactor=self) yield self.waitToStop self.assertEquals( set([ "user01_calendar1.ics", "user02_calendar1.ics", "user02_calendar2.ics" ]), set([child.basename() for child in outputDir.children()]))