Skip to content

Commit

Permalink
Merge pull request #1 from freedomofpress/ci
Browse files Browse the repository at this point in the history
add ci, tests, changelog
  • Loading branch information
kushaldas authored Dec 5, 2019
2 parents c061b7e + f6cf757 commit 6a5070c
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 4 deletions.
16 changes: 16 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
jobs:
test:
docker:
- image: circleci/python:3.7-buster
steps:
- checkout
- run:
name: Run tests
command: python3 -m unittest

workflows:
version: 2
per_pr:
jobs:
- test
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include LICENSE
include README.md
include changelog.md
include build-requirements.txt
include requirements.txt
include securedrop_log/*.py
Expand Down
Empty file added build-requirements.txt
Empty file.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 0.0.1

* Initial release.
4 changes: 2 additions & 2 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import logging
from oqubeslogging import OQubesLog
from securedrop_log import SecureDropLog

import ex2
import ex1


def main():
handler = OQubesLog("workvm", "logging")
handler = SecureDropLog("workvm", "logging")
logging.basicConfig(level=logging.DEBUG, handlers=[handler])
logger = logging.getLogger("example")

Expand Down
4 changes: 2 additions & 2 deletions journal-example.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import logging
from oqubeslogging import OQubesLog
from securedrop_log import SecureDropLog
from systemd import journal
import select


def main():
handler = OQubesLog("workvm", "logging")
handler = SecureDropLog("workvm", "logging")
logging.basicConfig(level=logging.DEBUG, handlers=[handler])
logger = logging.getLogger("example")
j = journal.Reader()
Expand Down
Empty file added requirements.txt
Empty file.
Empty file added tests/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions tests/test_logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from unittest import mock, TestCase

import securedrop_log


@mock.patch('securedrop_log.Popen')
class TestLogger(TestCase):
def test_singleton_there_can_be_only_one(self, mock_popen):
logger1 = securedrop_log.SecureDropLog('name', 'logvmname')
logger2 = securedrop_log.SecureDropLog('name', 'logvmname')

self.assertEqual(logger1.qubes_log, logger2.qubes_log)

def test_singleton_raises_exception_for_dev(self, mock_popen):
logger1 = securedrop_log.SecureDropLog('name', 'logvmname')

with self.assertRaises(Exception):
logger2 = securedrop_log.SecureDropLog('name2', 'logvmname2')

0 comments on commit 6a5070c

Please sign in to comment.