aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2023-12-04 07:28:02 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2023-12-29 07:29:12 +0100
commit0a56d27c3b0f590e0eef85666bb0d10d36041089 (patch)
tree22fb8c828ddf05919a2b19fa010f30a3be95e667 /tests
parentbaf3dc2691ea92ffb09ba107cb7abf2bb737122a (diff)
basic django project
Diffstat (limited to 'tests')
-rw-r--r--tests/test_app.py27
-rw-r--r--tests/test_mqtt.py32
2 files changed, 0 insertions, 59 deletions
diff --git a/tests/test_app.py b/tests/test_app.py
deleted file mode 100644
index 6cf29c5..0000000
--- a/tests/test_app.py
+++ /dev/null
@@ -1,27 +0,0 @@
-import os
-import unittest
-import unittest.mock
-
-from kerbana import config, create_app
-
-
-class TestBase(unittest.TestCase):
- def setUp(self):
- test_config = config.TestConfig()
- self.app = create_app(test_config)
- self.client = self.app.test_client()
-
- def test_root(self):
- res = self.client.get("/")
- self.assertEqual("Hello World!", res.data.decode())
-
-
-class TestConfig(unittest.TestCase):
- def test_default_config(self):
- app = create_app()
- self.assertEqual(app.config["SECRET_KEY"], "dev")
-
- @unittest.mock.patch.dict(os.environ, {"KERBANA_CONFIG": "no_such_file"})
- def test_kerbana_config_env_non_existing(self):
- app = create_app()
- self.assertEqual(app.config["SECRET_KEY"], "dev")
diff --git a/tests/test_mqtt.py b/tests/test_mqtt.py
deleted file mode 100644
index 20c1cf2..0000000
--- a/tests/test_mqtt.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import time
-import unittest
-
-from kerbana import config, create_app, mqtt
-
-
-class TestMQTT(unittest.TestCase):
- def setUp(self):
- test_config = config.TestConfig()
- self.app = create_app(test_config)
- self.mqtt = mqtt.MQTTClient(self.app)
- self.mqtt.connect()
- time.sleep(0.1)
- if not self.mqtt.connected:
- self.skipTest("Could not find an mqtt server")
-
- def tearDown(self):
- self.mqtt.disconnect(reconnect=False)
-
- def test_disconnect(self):
- # after disconnecting from the mqtt server, we should
- # automatically reconnect
- self.mqtt.disconnect()
- time.sleep(2)
- self.assertTrue(self.mqtt.connected)
-
- def test_disconnect_and_stay(self):
- # unless we really want to force a disconnection
- self.mqtt.disconnect(reconnect=False)
- time.sleep(2)
- self.assertFalse(self.mqtt.connected)
- self.assertFalse(self.mqtt.reconnect)