def test_all(self): """ One '--all' option will set exportAll to True """ eo = ExportOptions() eo.parseOptions(["--all"]) self.assertTrue(eo.exportAll)
def test_allContacts(self): """ '--all --contacts' will set exportAllType to "VCARD" """ eo = ExportOptions() eo.parseOptions(["--all", "--contacts"]) self.assertTrue(eo.exportAll) self.assertEquals(eo.exportAllType, "VCARD")
def test_oneUID(self): """ One '--uid' option will result in a single L{UIDExporter} object with no calendars in its list. """ eo = ExportOptions() eo.parseOptions(["--uid", "bob's your guid"]) self.assertEquals(len(eo.exporters), 1) exp = eo.exporters[0] self.assertIsInstance(exp, UIDExporter) self.assertEquals(exp.uid, "bob's your guid")
def test_oneRecord(self): """ One '--record' option will result in a single L{DirectoryExporter} object with no calendars in its list. """ eo = ExportOptions() eo.parseOptions(["--record", "users:bob"]) self.assertEquals(len(eo.exporters), 1) exp = eo.exporters[0] self.assertIsInstance(exp, DirectoryExporter) self.assertEquals(exp.recordType, "users") self.assertEquals(exp.shortName, "bob") self.assertEquals(exp.collections, [])
def test_homeAndCollections(self): """ The --collection option adds specific calendars to the last home that was exported. """ eo = ExportOptions() eo.parseOptions([ "--record", "users:bob", "--collection", "work stuff", "--uid", "jethroUID", "--collection=fun stuff" ]) self.assertEquals(len(eo.exporters), 2) exp = eo.exporters[0] self.assertEquals(exp.recordType, "users") self.assertEquals(exp.shortName, "bob") self.assertEquals(exp.collections, ["work stuff"]) exp = eo.exporters[1] self.assertEquals(exp.uid, "jethroUID") self.assertEquals(exp.collections, ["fun stuff"])
def test_homeAndCollections(self): """ The --collection option adds specific calendars to the last home that was exported. """ eo = ExportOptions() eo.parseOptions(["--record", "users:bob", "--collection", "work stuff", "--uid", "jethroUID", "--collection=fun stuff"]) self.assertEquals(len(eo.exporters), 2) exp = eo.exporters[0] self.assertEquals(exp.recordType, "users") self.assertEquals(exp.shortName, "bob") self.assertEquals(exp.collections, ["work stuff"]) exp = eo.exporters[1] self.assertEquals(exp.uid, "jethroUID") self.assertEquals(exp.collections, ["fun stuff"])
def test_outputFileSelection(self): """ The --output option selects the file to write to, '-' or no parameter meaning stdout; the L{ExportOptions.openOutput} method returns that file. """ eo = ExportOptions() eo.parseOptions([]) self.assertIdentical(eo.openOutput(), sys.stdout) eo = ExportOptions() eo.parseOptions(["--output", "-"]) self.assertIdentical(eo.openOutput(), sys.stdout) eo = ExportOptions() tmpnam = self.mktemp() eo.parseOptions(["--output", tmpnam]) self.assertEquals(eo.openOutput().name, tmpnam)