From 013a2b7c0173002b58b0cad142fd2f6437a30773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Meki=C4=87?= Date: Fri, 17 Jan 2025 22:56:01 +0100 Subject: [PATCH] Improve tests for the generated project --- freenit/project/.gitignore | 20 ++++++++++++++------ freenit/project/tests/client.py | 12 +++++------- tests/client.py | 1 - 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/freenit/project/.gitignore b/freenit/project/.gitignore index dd9f3cc..98e6c8a 100644 --- a/freenit/project/.gitignore +++ b/freenit/project/.gitignore @@ -1,17 +1,25 @@ -.provisioned +.coverage +.pytest_cache +__pycache__ +*.py[c,o] + ansible/group_vars/all ansible/inventory/inventory ansible/roles/* ansible/site.yml !ansible/roles/.keep !ansible/roles/devel -build/ + +build cbsd.conf -site.retry +coverage.xml +fstab +junit.xml +local_config.py project.mk +site.retry vars.mk -.ruff_cache -__pycache__ +dist/ +*.egg-info/ *.sqlite -*.egg-info diff --git a/freenit/project/tests/client.py b/freenit/project/tests/client.py index 2a2d9ab..1a8cee8 100644 --- a/freenit/project/tests/client.py +++ b/freenit/project/tests/client.py @@ -1,4 +1,3 @@ -import json import socket from fastapi.testclient import TestClient @@ -10,7 +9,7 @@ def url_for(self, name, host=socket.gethostname()): def get(self, endpoint): url = self.url_for(endpoint) - return super().get(url, cookies=self.cookies) + return super().get(url) def post(self, endpoint, data=None): url = self.url_for(endpoint) @@ -18,24 +17,23 @@ def post(self, endpoint, data=None): url, json=data, headers=self.headers, - cookies=self.cookies, ) return response def put(self, endpoint, data=None): url = self.url_for(endpoint) - response = super().put(url, json=data, cookies=self.cookies) + response = super().put(url, json=data) return response def patch(self, endpoint, data=None): url = self.url_for(endpoint) - response = super().patch(url, json=data, cookies=self.cookies) + response = super().patch(url, json=data) return response def delete(self, endpoint): url = self.url_for(endpoint) - return super().delete(url, cookies=self.cookies) + return super().delete(url) def login(self, user, endpoint="/auth/login"): data = { @@ -43,5 +41,5 @@ def login(self, user, endpoint="/auth/login"): "password": "Sekrit", } response = self.post(endpoint, data) - setattr(self, "cookies", response.cookies) + self.cookies = response.cookies return response diff --git a/tests/client.py b/tests/client.py index 941a2be..1a8cee8 100644 --- a/tests/client.py +++ b/tests/client.py @@ -1,4 +1,3 @@ -import json import socket from fastapi.testclient import TestClient