From 060568b14d23b4cbfdfe9c5c966c41a2f0f98265 Mon Sep 17 00:00:00 2001 From: TatLead Date: Fri, 15 Mar 2024 22:24:49 +0000 Subject: [PATCH] Add tests --- .dockerignore | 3 +++ tests/__init__.py | 0 tests/test_beammp.py | 19 +++++++++++++++++++ tests/test_factorio.py | 19 +++++++++++++++++++ tests/test_front.py | 19 +++++++++++++++++++ tests/test_palworld.py | 19 +++++++++++++++++++ tests/test_scum.py | 19 +++++++++++++++++++ 7 files changed, 98 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_beammp.py create mode 100644 tests/test_factorio.py create mode 100644 tests/test_front.py create mode 100644 tests/test_palworld.py create mode 100644 tests/test_scum.py diff --git a/.dockerignore b/.dockerignore index 23e52b8..c05e0d2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,6 +8,9 @@ # But do not ignore terms.md !terms.md +# Ignore all tests files +tests/ + # Ignore all log files *.log diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_beammp.py b/tests/test_beammp.py new file mode 100644 index 0000000..7338a42 --- /dev/null +++ b/tests/test_beammp.py @@ -0,0 +1,19 @@ +import pytest + +from protocols import MasterServer, BeamMP + + +@pytest.fixture +def instance(): + return BeamMP() + + +def test_job(instance: MasterServer): + assert instance.job() is None + + +def test_find(instance: MasterServer): + server = instance.collection.find_one() + host, port = server['ip'], server['port'] + result = instance.find(host=host, port=port) + assert result['ip'] == host and result['port'] == port diff --git a/tests/test_factorio.py b/tests/test_factorio.py new file mode 100644 index 0000000..df7496a --- /dev/null +++ b/tests/test_factorio.py @@ -0,0 +1,19 @@ +import pytest + +from protocols import MasterServer, Factorio + + +@pytest.fixture +def instance(): + return Factorio() + + +def test_job(instance: MasterServer): + assert instance.job() is None + + +def test_find(instance: MasterServer): + server = instance.collection.find_one() + host, port = str(server['host_address']).split(':') + result = instance.find(host=host, port=port) + assert server['host_address'] == result['host_address'] diff --git a/tests/test_front.py b/tests/test_front.py new file mode 100644 index 0000000..a0411a4 --- /dev/null +++ b/tests/test_front.py @@ -0,0 +1,19 @@ +import pytest + +from protocols import MasterServer, Front + + +@pytest.fixture +def instance(): + return Front() + + +def test_job(instance: MasterServer): + assert instance.job() is None + + +def test_find(instance: MasterServer): + server = instance.collection.find_one() + host, port = server['addr'], server['port'] + result = instance.find(host=host, port=port) + assert result['addr'] == host and result['port'] == port diff --git a/tests/test_palworld.py b/tests/test_palworld.py new file mode 100644 index 0000000..1212a59 --- /dev/null +++ b/tests/test_palworld.py @@ -0,0 +1,19 @@ +import pytest + +from protocols import MasterServer, Palworld + + +@pytest.fixture +def instance(): + return Palworld() + + +def test_job(instance: MasterServer): + assert instance.job() is None + + +def test_find(instance: MasterServer): + server = instance.collection.find_one() + host, port = server['address'], server['port'] + result = instance.find(host=host, port=port) + assert result['address'] == host and result['port'] == port diff --git a/tests/test_scum.py b/tests/test_scum.py new file mode 100644 index 0000000..5b4d146 --- /dev/null +++ b/tests/test_scum.py @@ -0,0 +1,19 @@ +import pytest + +from protocols import MasterServer, Scum + + +@pytest.fixture +def instance(): + return Scum() + + +def test_job(instance: MasterServer): + assert instance.job() is None + + +def test_find(instance: MasterServer): + server = instance.collection.find_one() + host, port = server['ip'], server['port'] + result = instance.find(host=host, port=port) + assert result['ip'] == host and result['port'] == port