Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 upgrade #16

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ services:
- postgresql

python:
- '2.7'
- '2.7_with_system_site_packages'
- '3.6'

addons:
postgresql: '9.4'
Expand All @@ -17,9 +18,6 @@ env:
- GEOKEY='>=1.6,<1.7' DJANGO='>=1.11,<1.12' DEPLOY=0
- GEOKEY='>=1.7,<1.8' DJANGO='>=1.11,<1.12' DEPLOY=1

virtualenv:
system_site_packages: true

install:
- sudo -E apt-get -yq update &>> ~/apt-get-update.log
- sudo apt-get install binutils libav-tools
Expand Down Expand Up @@ -54,4 +52,5 @@ deploy:
on:
tags: true
branch: master
python: '3.6'
condition: $DEPLOY = 1
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Install

geokey-epicollect requires:

- Python version 2.7
- Python version 2.7 or 3.6
- GeoKey version 1.6 or greater

Make sure the dependencies are installed:
Expand Down
2 changes: 1 addition & 1 deletion geokey_epicollect/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations

Expand Down
2 changes: 1 addition & 1 deletion geokey_epicollect/migrations/0002_epicollectmedia.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations

Expand Down
4 changes: 2 additions & 2 deletions geokey_epicollect/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def serialize_entry_to_xml(self, observation):
uploaded.text = observation.created_at.strftime('%Y-%m-%d %H:%M:%S')
entry.append(uploaded)

for key, value in observation.properties.iteritems():
for key, value in observation.properties.items():
tag_name = key.replace('-', '_')
if key not in self.static_fields:
tag_name = tag_name + '_' + str(observation.category.id)
Expand Down Expand Up @@ -340,7 +340,7 @@ def serialize_entry_to_tsv(self, observation):
line = line + 'created\t' + str(calendar.timegm(observation.created_at.utctimetuple())) + '\t'
line = line + 'uploaded\t' + observation.created_at.strftime('%Y-%m-%d %H:%M:%S') + '\t'

for key, value in observation.properties.iteritems():
for key, value in observation.properties.items():
tag_name = key.replace('-', '_')
if key not in self.static_fields:
tag_name = tag_name + '_' + str(observation.category.id)
Expand Down
22 changes: 11 additions & 11 deletions geokey_epicollect/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_get_not_existing_project(self):
response = view(request, project_id=45454544)
self.assertEqual(response.status_code, 403)
self.assertIn(
response.content,
response.content.decode('utf-8'),
'<error>The project must enabled for EpiCollect.</error>'
)

Expand Down Expand Up @@ -182,7 +182,7 @@ def test_upload_data(self):
view = EpiCollectUploadView.as_view()
response = view(request, project_id=project.id)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '1')
self.assertEqual(response.content.decode('utf-8'), '1')

def test_upload_data_with_media(self):
project = ProjectFactory.create(
Expand Down Expand Up @@ -214,7 +214,7 @@ def test_upload_data_with_media(self):
response = view(request, project_id=project.id)
self.assertEqual(response.status_code, 200)
self.assertEqual(EpiCollectMedia.objects.count(), 2)
self.assertEqual(response.content, '1')
self.assertEqual(response.content.decode('utf-8'), '1')

def test_upload_data_without_location(self):
project = ProjectFactory.create(
Expand Down Expand Up @@ -243,7 +243,7 @@ def test_upload_data_without_location(self):
view = EpiCollectUploadView.as_view()
response = view(request, project_id=project.id)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '0')
self.assertEqual(response.content.decode('utf-8'), '0')

def test_upload_category_does_not_exist(self):
project = ProjectFactory.create(
Expand All @@ -267,7 +267,7 @@ def test_upload_category_does_not_exist(self):
view = EpiCollectUploadView.as_view()
response = view(request, project_id=project.id)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '0')
self.assertEqual(response.content.decode('utf-8'), '0')

def test_upload_category_is_null(self):
project = ProjectFactory.create(
Expand All @@ -291,7 +291,7 @@ def test_upload_category_is_null(self):
view = EpiCollectUploadView.as_view()
response = view(request, project_id=project.id)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '0')
self.assertEqual(response.content.decode('utf-8'), '0')

def test_upload_checkboxes(self):
project = ProjectFactory.create(
Expand Down Expand Up @@ -325,7 +325,7 @@ def test_upload_checkboxes(self):
view = EpiCollectUploadView.as_view()
response = view(request, project_id=project.id)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '1')
self.assertEqual(response.content.decode('utf-8'), '1')

def test_upload_data_to_private_project(self):
project = ProjectFactory.create()
Expand All @@ -352,7 +352,7 @@ def test_upload_data_to_private_project(self):
view = EpiCollectUploadView.as_view()
response = view(request, project_id=project.id)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '0')
self.assertEqual(response.content.decode('utf-8'), '0')

def test_upload_image(self):
image = get_image()
Expand All @@ -374,7 +374,7 @@ def test_upload_image(self):
view = EpiCollectUploadView.as_view()
response = view(request, project_id=project.id)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '1')
self.assertEqual(response.content.decode('utf-8'), '1')

def test_upload_image_with_fullimage_flag(self):
image = get_image()
Expand All @@ -396,7 +396,7 @@ def test_upload_image_with_fullimage_flag(self):
view = EpiCollectUploadView.as_view()
response = view(request, project_id=project.id)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '1')
self.assertEqual(response.content.decode('utf-8'), '1')

def test_upload_image_with_wrong_file_name(self):
image = get_image()
Expand All @@ -418,7 +418,7 @@ def test_upload_image_with_wrong_file_name(self):
view = EpiCollectUploadView.as_view()
response = view(request, project_id=project.id)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '0')
self.assertEqual(response.content.decode('utf-8'), '0')


class DownloadDataTest(APITestCase):
Expand Down
2 changes: 1 addition & 1 deletion geokey_epicollect/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf.urls import url

from views import (
from geokey_epicollect.views import (
IndexPage, EpiCollectProject, EpiCollectUploadView, EpiCollectDownloadView
)

Expand Down
2 changes: 1 addition & 1 deletion geokey_epicollect/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from geokey.contributions.models import ImageFile, MediaFile
from geokey.users.models import User

from serializer import ProjectFormSerializer, DataSerializer
from geokey_epicollect.serializer import ProjectFormSerializer, DataSerializer
from .models import (
EpiCollectMedia,
EpiCollectProject as EpiCollectProjectModel
Expand Down