Skip to content

Commit

Permalink
Merge pull request #3 from josdem/feature/2
Browse files Browse the repository at this point in the history
[small]feature/2
  • Loading branch information
josdem committed Jun 29, 2024
2 parents cacc9d5 + 8ba8109 commit 5785be4
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.11.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: python -m unittest discover ${{ github.workspace }} -s tests
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ Python logger for [Vetlog](https://vetlog.org/) database analysis

- Python version `3.11.9` or above


#### To install dependencies
```bash
pip install -r requirements.txt
```

or

```bash
pip3 install -r requirements.txt
```

#### To run tests

```bash
Expand Down
Empty file added py_vetlog_logger/__init__.py
Empty file.
File renamed without changes.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest
pymox
Empty file added tests/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion tests/test_create_log.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import unittest
from python.create_log import *
from py_vetlog_logger.create_log import *

class FixedTest(unittest.TestCase):
path = "vetlog.log"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mock_log.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from unittest.mock import MagicMock
from python.create_log import *
from py_vetlog_logger.create_log import *
import unittest

class FixedTest(unittest.TestCase):
Expand Down
27 changes: 27 additions & 0 deletions tests/test_mox_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import mox
import logging
from py_vetlog_logger.create_log import *

class FixedTest(mox.MoxTestBase):
path = "vetlog.log"
def test_create_logger(self):
logger = self.mox.CreateMockAnything()
file_handler = self.mox.CreateMockAnything()
formatter = self.mox.CreateMockAnything()

self.mox.StubOutWithMock(logging, 'getLogger')
self.mox.StubOutWithMock(logging, 'FileHandler')
self.mox.StubOutWithMock(logging, 'Formatter')

logging.getLogger(self.path).AndReturn(logger)
logging.FileHandler(self.path).AndReturn(file_handler)
logging.Formatter('%(asctime)s:%(levelname)s:%(name)s:%(message)s').AndReturn(formatter)

logger.setLevel(logging.INFO)
logger.addHandler(file_handler)
file_handler.setFormatter(formatter)

self.mox.ReplayAll()
log = Logger(self.path)

assert log.logger == logger

0 comments on commit 5785be4

Please sign in to comment.