Beispiel #1
0
    def test_write_plain_message(self):
        """Verify the journal contains messages we write into it."""
        output = BytesIO()
        journal = TestJournal(output)
        initial_json_text = self.expect_message_text(journal.clock,
                                                     'Starting journal.')

        expect_stream = RecordOutputStream(BytesIO())
        expect_stream.append(initial_json_text)
        self.assertMessagesEqual(expect_stream.stream.getvalue(),
                                 output.getvalue())

        journal.write_message('A simple message.')
        message_json_text = self.expect_message_text(journal.clock,
                                                     'A simple message.')
        expect_stream.append(message_json_text)
        self.assertMessagesEqual(expect_stream.stream.getvalue(),
                                 output.getvalue())

        journal.terminate()
        final_json_text = self.expect_message_text(journal.clock,
                                                   'Finished journal.')
        expect_stream.append(final_json_text)
        self.assertMessagesEqual(expect_stream.stream.getvalue(),
                                 journal.final_content)
Beispiel #2
0
  def test_empty(self):
    """Verify the journal starts end ends with the correct JSON text."""

    output = BytesIO()
    journal = TestJournal(output)
    initial_json_text = self.expect_message_text(journal.clock,
                                                 'Starting journal.')
    expect_stream = RecordOutputStream(BytesIO())
    expect_stream.append(initial_json_text)

    self.assertMessagesEqual(expect_stream.stream.getvalue(), output.getvalue())

    journal.terminate()
    final_json_text = self.expect_message_text(journal.clock,
                                               'Finished journal.')
    expect_stream.append(final_json_text)
    self.assertMessagesEqual(expect_stream.stream.getvalue(), journal.final_content)
Beispiel #3
0
    def test_empty(self):
        """Verify the journal starts end ends with the correct JSON text."""

        output = StringIO()
        journal = TestJournal(output)
        initial_json_text = self.expect_message_text(journal.clock,
                                                     'Starting journal.')
        expect_stream = RecordOutputStream(StringIO())
        expect_stream.append(initial_json_text)

        self.assertEquals(expect_stream.stream.getvalue(), output.getvalue())

        journal.terminate()
        final_json_text = self.expect_message_text(journal.clock,
                                                   'Finished journal.')
        expect_stream.append(final_json_text)
        self.assertEquals(expect_stream.stream.getvalue(),
                          journal.final_content)
Beispiel #4
0
  def test_write_plain_message(self):
    """Verify the journal contains messages we write into it."""
    output = BytesIO()
    journal = TestJournal(output)
    initial_json_text = self.expect_message_text(journal.clock,
                                                 'Starting journal.')

    expect_stream = RecordOutputStream(BytesIO())
    expect_stream.append(initial_json_text)
    self.assertMessagesEqual(expect_stream.stream.getvalue(), output.getvalue())

    journal.write_message('A simple message.')
    message_json_text = self.expect_message_text(journal.clock,
                                                 'A simple message.')
    expect_stream.append(message_json_text)
    self.assertMessagesEqual(expect_stream.stream.getvalue(), output.getvalue())

    journal.terminate()
    final_json_text = self.expect_message_text(journal.clock,
                                               'Finished journal.')
    expect_stream.append(final_json_text)
    self.assertMessagesEqual(expect_stream.stream.getvalue(), journal.final_content)