示例#1
0
        def _doNonEquality(caldata):
            card1 = Card()
            card1.parse(StringIO.StringIO(caldata))

            card2 = Card()
            card2.parse(StringIO.StringIO(caldata))
            card2.addProperty(Property("X-FOO", "BAR"))

            self.assertNotEqual(card1, card2)
示例#2
0
        def _doNonEquality(caldata):
            card1 = Card()
            card1.parse(StringIO.StringIO(caldata))

            card2 = Card()
            card2.parse(StringIO.StringIO(caldata))
            card2.addProperty(Property("X-FOO", "BAR"))

            self.assertNotEqual(card1, card2)
示例#3
0
        def _doDuplicateRoundtrip(caldata, result):
            card = Card()
            card.parse(StringIO.StringIO(caldata))
            card = card.duplicate()

            s = StringIO.StringIO()
            card.generate(s)
            test = s.getvalue()
            self.assertEqual(test, result, "\n".join(difflib.unified_diff(test.splitlines(), result.splitlines())))
示例#4
0
        def _doEquality(caldata):
            card1 = Card()
            card1.parse(StringIO.StringIO(caldata))

            card2 = Card()
            card2.parse(StringIO.StringIO(caldata))

            self.assertEqual(
                card1, card2, "\n".join(difflib.unified_diff(str(card1).splitlines(), str(card2).splitlines()))
            )
示例#5
0
        def _doRoundtrip(caldata, resultdata=None):
            test1 = resultdata if resultdata is not None else caldata

            card = Card()
            card.parse(StringIO.StringIO(caldata))

            s = StringIO.StringIO()
            card.generate(s)
            test2 = s.getvalue()

            self.assertEqual(test1, test2, "\n".join(difflib.unified_diff(test1.splitlines(), test2.splitlines())))
示例#6
0
        def _doEquality(caldata):
            card1 = Card()
            card1.parse(StringIO.StringIO(caldata))

            card2 = Card()
            card2.parse(StringIO.StringIO(caldata))

            self.assertEqual(
                card1, card2, "\n".join(
                    difflib.unified_diff(
                        str(card1).splitlines(),
                        str(card2).splitlines())))
示例#7
0
        def _doDuplicateRoundtrip(caldata, result):
            card = Card()
            card.parse(StringIO.StringIO(caldata))
            card = card.duplicate()

            s = StringIO.StringIO()
            card.generate(s)
            test = s.getvalue()
            self.assertEqual(
                test, result, "\n".join(
                    difflib.unified_diff(test.splitlines(),
                                         result.splitlines())))
示例#8
0
        def _doRoundtrip(caldata, resultdata=None):
            test1 = resultdata if resultdata is not None else caldata

            card = Card()
            card.parse(StringIO.StringIO(caldata))

            s = StringIO.StringIO()
            card.generate(s)
            test2 = s.getvalue()

            self.assertEqual(
                test1,
                test2,
                "\n".join(
                    difflib.unified_diff(test1.splitlines(),
                                         test2.splitlines())),
            )
示例#9
0
 def fromStream(clazz, stream):
     """
     Construct a L{Component} from a stream.
     @param stream: a C{read()}able stream containing vCard data.
     @return: a L{Component} representing the first component described by
         C{stream}.
     """
     cal = Card()
     try:
         result = cal.parse(stream)
     except PyCalendarError:
         result = None
     if not result:
         stream.seek(0)
         raise InvalidVCardDataError("%s" % (stream.read(),))
     return clazz(None, pycard=cal)