Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed Apr 18, 2024
1 parent 656aa80 commit be27ea0
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/dev/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from django.test import TestCase

from argus.dev.utils import StressTester, DatabaseMismatchError

from argus.util.testing import connect_signals, disconnect_signals


class TestStressTester(TestCase):
def setUp(self):
disconnect_signals()
self.stresstester = StressTester("https://localhost", "token", 10, 1)

def tearDown(self):
connect_signals()

def test_verify_tags_raise_error_for_incorrect_tags(self):
expected_data = {
"tags": ["tag1=value1", "tag2=value2"],
}
actual_data = {
"tags": ["tag1=value2", "tag2=value1"],
}
with self.assertRaises(DatabaseMismatchError):
self.stresstester._verify_tags(actual_data, expected_data)

def test_verify_tags_does_not_raise_exception_for_correct_tags(self):
expected_data = {
"tags": ["tag1=value1", "tag2=value2"],
}
actual_data = {
"tags": ["tag1=value1", "tag2=value2"],
}
self.stresstester._verify_tags(actual_data, expected_data)

def test_verify_description_raise_error_for_incorrect_description(self):
expected_data = {
"description": "correct description",
}
actual_data = {
"tags": ["tag1=value2", "tag2=value1"],
}
with self.assertRaises(DatabaseMismatchError):
self.stresstester._verify_tags(actual_data, expected_data)

def test_verify_description_does_not_raise_exception_for_correct_description(self):
expected_data = {
"description": "correct description",
}
actual_data = {
"description": "incorrect description",
}
self.stresstester._verify_tags(actual_data, expected_data)

0 comments on commit be27ea0

Please sign in to comment.