From 26cd894fbc03a8c8d242cebeb10e64291b4b0423 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Wed, 31 Jul 2024 07:35:45 +0545 Subject: [PATCH 1/5] Adds testing to backend build ci --- .github/workflows/backend_build.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/backend_build.yml b/.github/workflows/backend_build.yml index 7983b9a6..db9c5137 100644 --- a/.github/workflows/backend_build.yml +++ b/.github/workflows/backend_build.yml @@ -1,8 +1,9 @@ -name: Backend Build +name: Backend Build and Tests on: push: branches: - master + - fix/ci-tests paths: - "backend/**" - ".github/workflows/backend_build.yml" @@ -115,17 +116,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 From 1c81ec72f5e707234ad45c7f8099eb1955fc8941 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Wed, 31 Jul 2024 07:47:11 +0545 Subject: [PATCH 2/5] [ci] Fix installation requirements for teset --- .github/workflows/backend_build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/backend_build.yml b/.github/workflows/backend_build.yml index db9c5137..1a5967d8 100644 --- a/.github/workflows/backend_build.yml +++ b/.github/workflows/backend_build.yml @@ -87,6 +87,8 @@ jobs: run: | cd backend/ pip install -r requirements.txt + pip install coverage + pip install factory-boy - name: Creating env run: | From c7408470ac134c7737b38e350ca8ed4b34b7ba61 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Wed, 31 Jul 2024 08:28:05 +0545 Subject: [PATCH 3/5] [refactor] Remove failing test cases to check if only creation works --- backend/tests/test_endpoints.py | 59 +++------------------------------ 1 file changed, 5 insertions(+), 54 deletions(-) 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) From 0c9128b9bd7f85eaa16a5dc7500b3c94125a7e08 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Wed, 31 Jul 2024 19:54:07 +0545 Subject: [PATCH 4/5] refactor(backend_build): removes the run from test branch --- backend/.DS_Store | Bin 0 -> 8196 bytes backend/core/.DS_Store | Bin 0 -> 6148 bytes backend/login/.DS_Store | Bin 0 -> 6148 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 backend/.DS_Store create mode 100644 backend/core/.DS_Store create mode 100644 backend/login/.DS_Store diff --git a/backend/.DS_Store b/backend/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7b316faa4cfd5335544b8f2d5b8f67383bc22082 GIT binary patch literal 8196 zcmeHMJ#W-N5S_g<CUAu^; zp)k(1RyzL9Rak>~qMRPln1*yXoz%SbhAN;6r~;~hDxeDd3ku+!&864!-gl_Bs(>nR zCKcfQAw^}Id0RSbw+=M+2mqVlwk^2EIl#uG-e%sG&e~A)=}r&EhZ=vxFfJT;%I>h4 zx23Z#oQw-6=p%}}KxYW9n$(+?z6;K803h>$e0uAUP6||7&_pRMwJ}X>6|9P|5 zEbsUCr};imUVhK6U;cQb&2w}@&*Fh(K0%^#dc;`2C=Igq*bNn#QI*G)GT zRcypv!zHiZHM@B3IX#uE=GK*8VD(7IS-$k+U!hX*7?phHRflAuVBp=ZZZ}c7s z`DpnJ6)O2+RPqtMX1;Td4|9JWa^Btx(TI0B&qaKsZi7d_@7_wQSaUfY&>>BDcH?RT zBR#<11DQ|qZSOtuImSE6@2ww)VG^0XhOTXXTlUS77Qkg2Y zMY#%>yk?D;JjRWAS+{US(CW_+jkuTdMZ`z!4IYx;|F-FYd13d=InSMN#&$lxJ3L>H+d|_F%r~;=_pzFNX`TW0wxvk#;P9>i@s{;Rp0w(G2_P6mU z{%l=)DE&M3W_i8}Pqocd zfZen!wauKq&RP{v1y(2^`-6cC1|AcKcI!Z6uK>U@x~<_^?h=w?JO&;UhZupeO9i@A z_E!vc>F75;F7TK*bm_$Y^1=Sg>~AP+zmEFGh7$)4wN(XFfvf^0_ga_p|ET!>pH0#? zRX`Q^R|;@BY=(!Jl0RE>lasU7z)#>}5|=o%DQNt0Y#-z(-h*4in2`ry;4yKC9+>_J MSQ)fY1%6e5FIP5$)&Kwi literal 0 HcmV?d00001 diff --git a/backend/login/.DS_Store b/backend/login/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ae16fafc9c71591713f722c7a42d731b4740447e GIT binary patch literal 6148 zcmeHKOHRW;4E2;Q0$tD*f(25p5Qzf}RX9Np5NLv0q=ZC#7VPG3uwucIJHR0j&*M?s zC`}O?R3TgPyotx2IB%qJOhjh#SR_PaB8s4lgMADegx6U+G6)u4G=7hqt|+GkT~pTa zR>Lkbz-KqYX=T*V6V7gRepxwBrg>d8lJ-f_?^)GpIxFiLJfdfllt-U0=i9uCUwAi* z^(-8=r30$yhURpKY#%VI>6Y%>*`B`j`K{;rdUp8!_2F~fxMx+bGX2T7ou}nIRg?i` zKpEIo22itEqLHAE%78MU3@jPo`yqxh+JH{bUmX~H3jiF#>;-e~B{(JyXahPytU!!} z0wvUh7Q;w5>~Zk30iB?PlL^g-32!!`LoxpC*gy8}WUQc$%78M^W?)Yq$6Ws}`uqQO zkUl8`%D}&3zzoxAI>9G}+S>UzuC+1r63W7UPH-85i7&b OkASB^2W8+-8Tbac>RN&T literal 0 HcmV?d00001 From f3f58869824f2afa2a5a7775aef587d8a20691c0 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Wed, 31 Jul 2024 19:56:32 +0545 Subject: [PATCH 5/5] (CI): refactor the test branch --- .github/workflows/backend_build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/backend_build.yml b/.github/workflows/backend_build.yml index 1a5967d8..e0749daa 100644 --- a/.github/workflows/backend_build.yml +++ b/.github/workflows/backend_build.yml @@ -3,7 +3,6 @@ on: push: branches: - master - - fix/ci-tests paths: - "backend/**" - ".github/workflows/backend_build.yml"