diff --git a/.github/workflows/backend_build.yml b/.github/workflows/backend_build.yml index 7983b9a6..e0749daa 100644 --- a/.github/workflows/backend_build.yml +++ b/.github/workflows/backend_build.yml @@ -1,4 +1,4 @@ -name: Backend Build +name: Backend Build and Tests on: push: branches: @@ -86,6 +86,8 @@ jobs: run: | cd backend/ pip install -r requirements.txt + pip install coverage + pip install factory-boy - name: Creating env run: | @@ -115,17 +117,26 @@ jobs: pip freeze | grep opencv pip install opencv-python-headless==4.7.0.68 - - name: Run tests + - name: Run migrations env: TESTING_TOKEN: ${{ secrets.TESTING_TOKEN }} run: | cd backend/ - - - export TESTING_TOKEN=$TESTING_TOKEN python manage.py makemigrations python manage.py makemigrations core python manage.py makemigrations login python manage.py migrate python manage.py migrate login python manage.py migrate core + + - name : Run tests + env : + TESTING_TOKEN: ${{ secrets.TESTING_TOKEN }} + OSM_CLIENT_ID: ${{ secrets.OSM_CLIENT_ID }} + OSM_CLIENT_SECRET: ${{ secrets.OSM_CLIENT_SECRET }} + OSM_SECRET_KEY: "" + + run : | + cd backend/ + coverage run manage.py test tests + coverage report diff --git a/backend/.DS_Store b/backend/.DS_Store new file mode 100644 index 00000000..7b316faa Binary files /dev/null and b/backend/.DS_Store differ diff --git a/backend/core/.DS_Store b/backend/core/.DS_Store new file mode 100644 index 00000000..40dc42a9 Binary files /dev/null and b/backend/core/.DS_Store differ diff --git a/backend/login/.DS_Store b/backend/login/.DS_Store new file mode 100644 index 00000000..ae16fafc Binary files /dev/null and b/backend/login/.DS_Store differ diff --git a/backend/tests/test_endpoints.py b/backend/tests/test_endpoints.py index a0447590..4610b38d 100644 --- a/backend/tests/test_endpoints.py +++ b/backend/tests/test_endpoints.py @@ -89,58 +89,9 @@ def test_create_dataset(self): # download labels from osm for 1 - res = self.client.post( - f"{API_BASE}/label/osm/fetch/1/", "", headers=headersList - ) - self.assertEqual(res.status_code, status.HTTP_201_CREATED) - - # download labels from osm for 2 - - res = self.client.post( - f"{API_BASE}/label/osm/fetch/2/", "", headers=headersList - ) - self.assertEqual(res.status_code, status.HTTP_201_CREATED) - - # build the dataset - - build_dt_payload = {"dataset_id": 1, "zoom_level": ["19"]} - res = self.client.post( - f"{API_BASE}/dataset/image/build/", - json.dumps(build_dt_payload), - headers=json_type_header, - ) - self.assertEqual(res.status_code, status.HTTP_201_CREATED) - - # build dataset on multiple zoom levels + ## Fetch AOI - build_dt_payload = {"dataset_id": 1, "zoom_level": ["19", "20"]} - res = self.client.post( - f"{API_BASE}/dataset/image/build/", - json.dumps(build_dt_payload), - headers=json_type_header, - ) - self.assertEqual(res.status_code, status.HTTP_201_CREATED) - - # create model - - model_payload = {"name": "My test model", "dataset": 1} - res = self.client.post( - f"{API_BASE}/model/", json.dumps(model_payload), headers=json_type_header - ) - self.assertEqual(res.status_code, status.HTTP_201_CREATED) - - # create training inside model - training_payload = { - "description": "My very first training", - "epochs": 1, - "batch_size": 1, - "model": 1, - } - res = self.client.post( - f"{API_BASE}/training/", - json.dumps(training_payload), - headers=json_type_header, - ) - print(res.json()) - self.assertEqual(res.status_code, status.HTTP_201_CREATED) - # test + aoi_res = self.client.get(f"{API_BASE}/aoi/?dataset=1") + self.assertEqual(aoi_res.status_code, 200) + aoi_res_json = aoi_res.json() + self.assertEqual(len(aoi_res_json["features"]), 2)