old_console/logstash/tests/test_license.py
2024-11-02 14:12:45 +03:00

45 lines
1.8 KiB
Python

import pytest
from unittest.mock import patch
from inputs.enums import LogInputType
from inputs.models import LogInput
from inputs.services.inputs import get_allowed_input_count
FULL_LICENSE = {"uuid": "5fcda3dd-8b32-47cd-96d4-1b39f68cf2f3", "hardware": "f5fbe2bd-872c-31f6-9af2-2b8eccdd9dd1",
"customer": "Developers", "product": "ARMA Console", "type": "ENTERPRISE",
"features": ["event_processing"], "options": {"event_sources": "100"},
"evaluationStart": "2021-08-26T19:58:03.674613245Z", "evaluationEnd": "2021-09-25T19:58:03.674613245Z"}
SMALL_LICENSE = {"uuid": "5fcda3dd-8b32-47cd-96d4-1b39f68cf2f3", "hardware": "f5fbe2bd-872c-31f6-9af2-2b8eccdd9dd1",
"customer": "Developers", "product": "ARMA Console", "type": "ENTERPRISE",
"features": ["event_processing"], "options": {"event_sources": "1"},
"evaluationStart": "2021-08-26T19:58:03.674613245Z", "evaluationEnd": "2021-09-25T19:58:03.674613245Z"}
@pytest.mark.django_db
class TestAllowedInputs:
@pytest.mark.unit
@patch("inputs.services.inputs.get_license_info")
def test_check_good_input_count(self, mock_function):
mock_function.return_value = FULL_LICENSE
assert get_allowed_input_count() == 100
@pytest.mark.unit
@patch("inputs.services.inputs.get_license_info")
def test_check_bad_input_count(self, mock_function):
mock_function.return_value = None
assert get_allowed_input_count() == 0
@pytest.mark.unit
@patch("inputs.services.inputs.get_license_info")
def test_check_change_input_count(self, mock_function):
mock_function.return_value = SMALL_LICENSE
assert get_allowed_input_count() == 1
LogInput.objects.create(label="1", type=LogInputType.ARMAIF, can_delete=False)
assert get_allowed_input_count() == 0