This repository has been archived by the owner on Nov 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(logging): Refactored rendering interface to use navigators
Rather than using file paths, the API takes journal navigators. Added StreamJournalNavigator to take the place of file paths.
- Loading branch information
Eric Wiseblatt
committed
Sep 25, 2018
1 parent
fa10283
commit c6a6570
Showing
8 changed files
with
184 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Copyright 2018 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Test citest.reporting.html_renderer module.""" | ||
|
||
import os | ||
import shutil | ||
import tempfile | ||
import unittest | ||
|
||
from citest.base import ( | ||
Journal, | ||
StreamJournalNavigator) | ||
|
||
|
||
class StreamNavigatorTest(unittest.TestCase): | ||
# pylint: disable=missing-docstring | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.temp_dir = tempfile.mkdtemp(prefix='journal_nav_test') | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
shutil.rmtree(cls.temp_dir) | ||
|
||
def test_iterator(self): | ||
journal = Journal() | ||
path = os.path.join(self.temp_dir, 'test_iterator.journal') | ||
expect = [] | ||
|
||
journal.open_with_path(path, TestString='TestValue', TestNum=123) | ||
expect.append({'_type': 'JournalMessage', | ||
'_value': 'Starting journal.', | ||
'TestString': 'TestValue', | ||
'TestNum': 123}) | ||
|
||
journal.write_message('Initial Message') | ||
expect.append({'_type': 'JournalMessage', '_value': 'Initial Message'}) | ||
|
||
journal.begin_context('OUTER', TestProperty='BeginOuter') | ||
expect.append({'_type': 'JournalContextControl', | ||
'control': 'BEGIN', | ||
'_title': 'OUTER', | ||
'TestProperty': 'BeginOuter'}) | ||
|
||
journal.write_message('Context Message', format='pre') | ||
expect.append({'_type': 'JournalMessage', '_value': 'Context Message', | ||
'format': 'pre'}) | ||
|
||
journal.end_context(TestProperty='END OUTER') | ||
expect.append({'_type': 'JournalContextControl', | ||
'control': 'END', | ||
'TestProperty': 'END OUTER'}) | ||
|
||
journal.terminate(EndProperty='xyz') | ||
expect.append({'_type': 'JournalMessage', | ||
'_value': 'Finished journal.', | ||
'EndProperty': 'xyz'}) | ||
|
||
# We're going to pop off expect, so reverse it | ||
# so that we can check in order. | ||
expect.reverse() | ||
navigator = StreamJournalNavigator.new_from_path(path) | ||
for record in navigator: | ||
del(record['_thread']) | ||
del(record['_timestamp']) | ||
self.assertEquals(record, expect.pop()) | ||
self.assertEquals([], expect) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |