From 8248004bce170fa5b73c4b179b2406ca7c84ca62 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Tue, 5 Apr 2022 12:48:18 +0200 Subject: [PATCH] Island, UT: Use count_documents instead of count * count() is deprecated * pytest.mark.usefixtureS --- monkey/monkey_island/cc/setup/mongo/database_initializer.py | 2 +- .../cc/services/reporting/test_stolen_credentials.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/setup/mongo/database_initializer.py b/monkey/monkey_island/cc/setup/mongo/database_initializer.py index 9a6054ca4..35b22b87f 100644 --- a/monkey/monkey_island/cc/setup/mongo/database_initializer.py +++ b/monkey/monkey_island/cc/setup/mongo/database_initializer.py @@ -32,7 +32,7 @@ def _try_store_mitigations_on_mongo(): mitigation_collection_name = AttackMitigations.COLLECTION_NAME try: mongo.db.validate_collection(mitigation_collection_name) - if mongo.db.attack_mitigations.count() == 0: + if mongo.db.attack_mitigations.count_documents({}) == 0: raise errors.OperationFailure( "Mitigation collection empty. Try dropping the collection and running again" ) diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/reporting/test_stolen_credentials.py b/monkey/tests/unit_tests/monkey_island/cc/services/reporting/test_stolen_credentials.py index e3a7f6570..7a0e0aeca 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/reporting/test_stolen_credentials.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/reporting/test_stolen_credentials.py @@ -35,7 +35,7 @@ def fake_monkey(): return monkey.id -@pytest.mark.usefixture("uses_database") +@pytest.mark.usefixtures("uses_database") def test_get_credentials(fake_monkey): StolenCredentials( identities=fake_credentials["identities"],