Skip to content

Commit 48a53af

Browse files
committed
Switched automated testing platform to github actions.
1 parent 9a2bf33 commit 48a53af

File tree

8 files changed

+75
-69
lines changed

8 files changed

+75
-69
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Automated testing for django-raster
2+
3+
on: [push]
4+
5+
jobs:
6+
flake8:
7+
name: Run the flake8 linter
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout package
11+
uses: actions/checkout@v2
12+
with:
13+
path: .
14+
- name: Install flake8
15+
run: pip install flake8
16+
- name: Lint with Flake8
17+
run: flake8 .
18+
19+
isort:
20+
name: Run the isort linter
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout package
24+
uses: actions/checkout@v2
25+
with:
26+
path: .
27+
- name: Install isort
28+
run: pip install isort
29+
- name: Lint with isort
30+
run: isort --check --diff .
31+
32+
test:
33+
name: Run django unit tests suite
34+
runs-on: ubuntu-18.04
35+
services:
36+
postgres:
37+
image: postgis/postgis:10-2.5
38+
env:
39+
# must specify password for PG Docker container image, see: https://registry.hub.docker.com/_/postgres?tab=description&page=1&name=10
40+
POSTGRES_PASSWORD: password
41+
POSTGRES_DB: raster_test
42+
ports:
43+
- 5432:5432
44+
# needed because the postgres container does not provide a healthcheck
45+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
46+
steps:
47+
- name: Checkout package
48+
uses: actions/checkout@v2
49+
with:
50+
path: .
51+
- name: Install dependencies
52+
run: |
53+
sudo apt-get install -y gdal-bin python3-pip
54+
pip3 install --upgrade importlib-metadata
55+
pip3 install celery==4.3.1 django numpy Pillow django-colorful pyparsing boto3 psycopg2-binary mock
56+
- name: Run tests
57+
run: PYTHONPATH=$PYTHONPATH:$PWD django-admin test ./tests
58+
env:
59+
DB_PASSWORD: password
60+
DB_NAME: raster_test
61+
DJANGO_SETTINGS_MODULE: tests.testproj.settings

.travis.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

raster/algebra/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy
55

66
ALGEBRA_PIXEL_TYPE_GDAL = 7
7-
ALGEBRA_PIXEL_TYPE_NUMPY = "Float64"
7+
ALGEBRA_PIXEL_TYPE_NUMPY = "float64"
88

99
LPAR = "("
1010
RPAR = ")"

raster/urls.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@
2424
name='pixel',
2525
),
2626

27-
# Raster legend endpoint
27+
# Raster legend endpoints.
2828
url(
29-
r'^legend(?:/(?P<legend_id>[^/]+))?/$',
29+
r'^legend$',
3030
LegendView.as_view(),
3131
name='legend',
3232
),
33+
url(
34+
r'^legend/(?P<legend_id>[^/]+)$',
35+
LegendView.as_view(),
36+
name='legend-detail',
37+
),
3338

3439
# Exporter endpoint
3540
url(

raster/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def get_rgb(self, data):
432432

433433
class LegendView(RasterView):
434434

435-
def get(self, request, legend_id):
435+
def get(self, request, legend_id=None):
436436
"""
437437
Returns the legend for this layer as a json string. The legend is a list of
438438
legend entries with the attributes "name", "expression" and "color".

tests/test_code_sanity.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/test_legend_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_tms_legend_url_from_layer_id(self):
1616
self.assertEqual(response.status_code, 200)
1717

1818
def test_tms_legend_url_error_wrong_legend_id(self):
19-
url = reverse('legend', kwargs={'legend_id': '9999'})
19+
url = reverse('legend-detail', kwargs={'legend_id': '9999'})
2020
response = self.client.get(url)
2121
self.assertEqual(response.status_code, 404)
2222

@@ -31,7 +31,7 @@ def test_tms_legend_url_error_no_id(self):
3131
self.assertEqual(response.status_code, 404)
3232

3333
def test_tms_legend_url_from_legend_id(self):
34-
url = reverse('legend', kwargs={'legend_id': self.legend.id})
34+
url = reverse('legend-detail', kwargs={'legend_id': self.legend.id})
3535
response = self.client.get(url)
3636
self.assertEqual(
3737
json.loads(response.content.strip().decode()),

tests/testproj/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
'context_processors': [
4444
'django.contrib.auth.context_processors.auth',
4545
'django.contrib.messages.context_processors.messages',
46+
'django.template.context_processors.request',
4647
],
4748
},
4849
},
@@ -54,3 +55,5 @@
5455

5556
CELERY_TASK_ALWAYS_EAGER = True
5657
CELERY_TASK_EAGER_PROPAGATES = True
58+
59+
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

0 commit comments

Comments
 (0)