Exemplo n.º 1
0
    def test_write(self):
        mock_out = MagicMock()
        writer = CalendarWriter(mock_out)

        writer.write("I like writing stuff")

        mock_out.write.assert_called_once_with(b"I like writing stuff")
Exemplo n.º 2
0
    def test_write_wrap(self):
        out = six.BytesIO()
        writer = CalendarWriter(out)

        message = (
            "This is a very long piece of text which will have to be wrapped "
            "otherwise it would be toooooooo long. It might even have to be "
            "wrapped twice because it's just that long."
        )

        writer.write(message)

        value = out.getvalue()
        # Don't strip the space after newline, otherwise line length would
        # be off by 1.
        lines = value.split(b"\r\n")

        self.assertEqual(max(len(l) for l in lines), 75)
        self.assertFalse(value.endswith(b"\r\n "))