Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Tests for LogsAPI (#71)
Browse files Browse the repository at this point in the history
* log tests

* unused import deleted

* Add flake8-quotes. Reformat code with double-quotes style. (#68)

* Add flake8-quotes

* Add double-quotes checker

* Format to double quotes

* Format to double quotes

* Remove useless test.

* Force line-length=120

* Force line-length < 120

* Use only double quotes

* test class name change

* delete unused import

* Path to str

* parametrize

Co-authored-by: Kamil Górski <[email protected]>
  • Loading branch information
tomaszwarda and kagrski authored Jan 9, 2023
1 parent 517dfd1 commit 7cd1f7d
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions vmngclient/tests/test_logs_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import unittest
from pathlib import Path
from unittest.mock import patch

from parameterized import parameterized # type: ignore

from vmngclient.api.logs_api import LogsAPI


class TestLogsAPI(unittest.TestCase):
def setUp(self) -> None:
self.logs = [
{"logid": "12345", "logmessage": "message from log 1", "tenant": "tenant234", "entry_time": 1671028426000},
{"logid": "67890", "logmessage": "message from log 2", "tenant": "tenant987", "entry_time": 1671028426000},
]

@patch("vmngclient.session.vManageSession")
def test_get_auditlogs_file_path_not_provided(self, mock_session):
# Arrange
mock_session.get_data.return_value = self.logs
default_file_path = Path(__file__).parents[1].joinpath("api").joinpath("audit.log")
# Act
LogsAPI(mock_session).get_auditlogs()
does_file_exist = default_file_path.is_file()
# Assert
self.assertTrue(does_file_exist)

@parameterized.expand([["test_file.log"], ["other_test_file.log"]])
@patch("vmngclient.session.vManageSession")
def test_get_auditlogs_file_path(self, file_name, mock_session):
# Arrange
mock_session.get_data.return_value = self.logs
file_path = Path(__file__).parents[2].joinpath(file_name)
# Act
LogsAPI(mock_session).get_auditlogs(file_path=file_name)
does_file_exist = file_path.is_file()
# Assert
self.assertTrue(does_file_exist)

0 comments on commit 7cd1f7d

Please sign in to comment.