コード例 #1
0
ファイル: test_export.py プロジェクト: advatar/CalendarServer
 def test_all(self):
     """
     One '--all' option will set exportAll to True
     """
     eo = ExportOptions()
     eo.parseOptions(["--all"])
     self.assertTrue(eo.exportAll)
コード例 #2
0
ファイル: test_export.py プロジェクト: advatar/CalendarServer
 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")
コード例 #3
0
 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")
コード例 #4
0
 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")
コード例 #5
0
 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, [])
コード例 #6
0
 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, [])
コード例 #7
0
 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"])
コード例 #8
0
 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"])
コード例 #9
0
 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)
コード例 #10
0
 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)