diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 68c2bec4c9aa03ce004a48080fd247d3f4637381..ff15e98df2a18e834df1313157b0416123e2b1e0 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -8,12 +8,6 @@ services: start_period: 2s retries: 30 env_file: env/netbox.env - logging: - driver: "syslog" - options: - syslog-address: "tcp://gra1-63cfda8371ef06f3c6bf175c.gra1.logs.ovh.com:6514" - syslog-format: "rfc5424" - tag: "netbox" netbox-worker: image: "code.europa.eu:4567/digit-c4/netbox-plugins:${TAG}" env_file: env/netbox.env @@ -26,12 +20,6 @@ services: netbox-housekeeping: image: "code.europa.eu:4567/digit-c4/netbox-plugins:${TAG}" env_file: env/netbox.env - logging: - driver: "syslog" - options: - syslog-address: "tcp://gra1-63cfda8371ef06f3c6bf175c.gra1.logs.ovh.com:6514" - syslog-format: "rfc5424" - tag: "netbox-housekeeping" postgres: env_file: env/postgres.env logging: @@ -42,17 +30,5 @@ services: tag: "netbox-postgres" redis: env_file: env/redis.env - logging: - driver: "syslog" - options: - syslog-address: "tcp://gra1-63cfda8371ef06f3c6bf175c.gra1.logs.ovh.com:6514" - syslog-format: "rfc5424" - tag: "netbox-redis" redis-cache: env_file: env/redis-cache.env - logging: - driver: "syslog" - options: - syslog-address: "tcp://gra1-63cfda8371ef06f3c6bf175c.gra1.logs.ovh.com:6514" - syslog-format: "rfc5424" - tag: "netbox-cache" diff --git a/tests/e2e/workplace/test_create_device.py b/tests/e2e/workplace/test_create_device.py new file mode 100644 index 0000000000000000000000000000000000000000..95c4404d59a9be131c536d0255efdc23e68f4203 --- /dev/null +++ b/tests/e2e/workplace/test_create_device.py @@ -0,0 +1,100 @@ +"""Test case for Netbox Metrics""" + +import unittest +import os +import json +import requests + +HOST = os.getenv("HOST", default="localhost") +PORT = os.getenv("PORT", default="8080") +API_KEY = os.getenv("API_KEY", "only4testingpurpose") + + +class TestCreateDevice(unittest.TestCase): + """Test case for Device creation""" + + device_role = None + site = None + + def setUp(self) -> None: + response = requests.post( + url=f"http://{HOST}:{PORT}/api/dcim/device-roles/", + json={"name": "Switch", "slug": "switch"}, + headers={"Authorization": f"Token {API_KEY}"}, + timeout=5, + ) + + self.assertEqual(response.status_code, 201) + + self.device_role = json.loads(response.content) + + self.assertEqual(self.device_role["name"], "Switch") + self.assertEqual(self.device_role["slug"], "switch") + + response = requests.post( + url=f"http://{HOST}:{PORT}/api/dcim/sites/", + json={"name": "ispra", "slug": "ispra"}, + headers={"Authorization": f"Token {API_KEY}"}, + timeout=5, + ) + + self.assertEqual(response.status_code, 201) + + self.site = json.loads(response.content) + + self.assertEqual(self.site["name"], "ispra") + self.assertEqual(self.site["slug"], "ispra") + + def tearDown(self) -> None: + response = requests.delete( + url=f"http://{HOST}:{PORT}/api/dcim/device-roles/", + json=[ + { + "id": self.device_role["id"], + "name": self.device_role["name"], + "slug": self.device_role["slug"], + } + ], + headers={"Authorization": f"Token {API_KEY}"}, + timeout=5, + ) + + self.assertEqual(response.status_code, 204) + + response = requests.delete( + url=f"http://{HOST}:{PORT}/api/dcim/sites/", + json=[ + { + "id": self.site["id"], + "name": self.site["name"], + "slug": self.site["slug"], + } + ], + headers={"Authorization": f"Token {API_KEY}"}, + timeout=5, + ) + + self.assertEqual(response.status_code, 204) + + def test_that_a_device_is_created(self) -> None: + """Test that device is created""" + + response = requests.post( + url=f"http://{HOST}:{PORT}/api/dcim/devices/", + json={ + "name": "test_switch", + "role": { + "slug": "switch", + }, + "device_type": {"slug": "cisco-c9300-48p-e"}, + "site": {"slug": "ispra"}, + }, + headers={"Authorization": f"Token {API_KEY}"}, + timeout=5, + ) + + self.assertEqual(response.status_code, 201) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/requirements.e2e.txt b/tests/requirements.e2e.txt index 39e0c53118f32ab7d67efe760b1cf087c7d2ce89..0116ddabe0fc4f469f9e985ce076e1e740c704f4 100644 --- a/tests/requirements.e2e.txt +++ b/tests/requirements.e2e.txt @@ -1,2 +1,3 @@ requests==2.30.0 pytest +pylint