mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-22 11:23:55 +02:00
Chore/rework workflow (#52)
* Reworked the lint action * Removed the file change requirement * Repaired mypy * Repaired pip-audit
This commit is contained in:
@ -10,7 +10,7 @@ from aki_prj23_transparenzregister.utils.mongo.news_mongo_service import (
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_mongo_connector(mocker) -> Mock:
|
||||
def mock_mongo_connector(mocker: Mock) -> Mock:
|
||||
"""Mock MongoConnector class.
|
||||
|
||||
Args:
|
||||
@ -37,7 +37,7 @@ def mock_collection() -> Mock:
|
||||
return Mock()
|
||||
|
||||
|
||||
def test_init(mock_mongo_connector, mock_collection):
|
||||
def test_init(mock_mongo_connector: Mock, mock_collection: Mock) -> None:
|
||||
"""Test CompanyMongoService constructor.
|
||||
|
||||
Args:
|
||||
@ -49,7 +49,7 @@ def test_init(mock_mongo_connector, mock_collection):
|
||||
assert service.collection == mock_collection
|
||||
|
||||
|
||||
def test_get_all(mock_mongo_connector, mock_collection):
|
||||
def test_get_all(mock_mongo_connector: Mock, mock_collection: Mock) -> None:
|
||||
mock_mongo_connector.database = {"news": mock_collection}
|
||||
service = MongoNewsService(mock_mongo_connector)
|
||||
|
||||
@ -57,7 +57,9 @@ def test_get_all(mock_mongo_connector, mock_collection):
|
||||
assert service.get_all() == []
|
||||
|
||||
|
||||
def test_get_by_id_with_result(mock_mongo_connector, mock_collection):
|
||||
def test_get_by_id_with_result(
|
||||
mock_mongo_connector: Mock, mock_collection: Mock
|
||||
) -> None:
|
||||
mock_mongo_connector.database = {"news": mock_collection}
|
||||
service = MongoNewsService(mock_mongo_connector)
|
||||
|
||||
@ -69,7 +71,7 @@ def test_get_by_id_with_result(mock_mongo_connector, mock_collection):
|
||||
assert service.get_by_id("foadh") == {}
|
||||
|
||||
|
||||
def test_get_by_id_no_result(mock_mongo_connector, mock_collection):
|
||||
def test_get_by_id_no_result(mock_mongo_connector: Mock, mock_collection: Mock) -> None:
|
||||
mock_mongo_connector.database = {"news": mock_collection}
|
||||
service = MongoNewsService(mock_mongo_connector)
|
||||
|
||||
@ -77,7 +79,7 @@ def test_get_by_id_no_result(mock_mongo_connector, mock_collection):
|
||||
assert service.get_by_id("foadh") is None
|
||||
|
||||
|
||||
def test_insert(mock_mongo_connector, mock_collection):
|
||||
def test_insert(mock_mongo_connector: Mock, mock_collection: Mock) -> None:
|
||||
mock_mongo_connector.database = {"news": mock_collection}
|
||||
service = MongoNewsService(mock_mongo_connector)
|
||||
|
||||
@ -86,17 +88,17 @@ def test_insert(mock_mongo_connector, mock_collection):
|
||||
) as mock_in:
|
||||
mock_collection.insert_one.return_value = {}
|
||||
mock_in.return_value = {}
|
||||
assert service.insert({}) == {}
|
||||
assert service.insert({}) == {} # type: ignore
|
||||
|
||||
|
||||
def test_transform_ingoing():
|
||||
news = News("42", None, None, None, None)
|
||||
def test_transform_ingoing() -> None:
|
||||
news = News("42", None, None, None, None) # type: ignore
|
||||
result = MongoEntryTransformer.transform_ingoing(news)
|
||||
assert result["_id"] == "42"
|
||||
assert "id" not in result
|
||||
|
||||
|
||||
def test_transform_outgoing():
|
||||
def test_transform_outgoing() -> None:
|
||||
data = {
|
||||
"_id": "4711",
|
||||
"title": "Hello",
|
||||
|
Reference in New Issue
Block a user