Skip to content

Commit

Permalink
merge release/1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
CI committed Dec 6, 2018
2 parents 516c046 + b7eaaaf commit bda56a1
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 181 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.4.2
=====
* Possible fix for deadlock issue
* Update requirements, django security alert, and moved to psycopg2-binary
* Clean up tests

1.4.1
=====
* Update managers for Locations
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tox-pipenv = "==1.6.0"
pytest-django = "*"
pytest-pythonpath = "*"
djangorestframework = "*"
"psycopg2" = "*"
"psycopg2-binary" = "*"
factory-boy = "*"
drf-api-checker = ">=0.3"
django-webtest = "*"
Expand Down
330 changes: 157 additions & 173 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/unicef_locations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NAME = "unicef-locations"
VERSION = __version__ = "1.4.1"
VERSION = __version__ = "1.4.2"
default_app_config = "unicef_locations.apps.Config"
18 changes: 18 additions & 0 deletions src/unicef_locations/migrations/0005_auto_20181206_1127.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.4 on 2018-12-06 11:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('locations', '0004_pcode_remap_related'),
]

operations = [
migrations.AlterField(
model_name='location',
name='is_active',
field=models.BooleanField(blank=True, default=True, verbose_name='Active'),
),
]
3 changes: 3 additions & 0 deletions src/unicef_locations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def update_sites_from_cartodb(carto_table_pk):

# wrap Location tree updates in a transaction, to prevent an invalid tree state due to errors
with transaction.atomic():
# should write lock the locations table until the tree is rebuilt
Location.objects.all_locations().select_for_update().only('id')

# disable tree 'generation' during single row updates, rebuild the tree after.
# this should prevent errors happening (probably)due to invalid intermediary tree state
with Location.objects.disable_mptt_updates():
Expand Down
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

import pytest

from unicef_locations.tests.factories import LocationFactory


@pytest.fixture()
def location(db):
from unicef_locations.tests.factories import LocationFactory
return LocationFactory()


@pytest.fixture()
def locations3(db):
return [location(db) for _ in range(3)]
return [LocationFactory() for _ in range(3)]


@pytest.fixture()
Expand Down
2 changes: 2 additions & 0 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ def test_admin_location(django_app, admin_user, locations3):
response = django_app.get(url, user=admin_user)
assert response


def test_admin_location_filter(django_app, admin_user, locations3):
url = "{}?is_active=True&o=1".format(reverse('admin:locations_location_changelist'))
response = django_app.get(url, user=admin_user)

assert response


def test_admin_location_edit(django_app, admin_user, location):
url = reverse('admin:locations_location_change', args=[location.id])
response = django_app.get(url, user=admin_user)
Expand Down
7 changes: 4 additions & 3 deletions tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def test_sql_client_error(self):
"""
self.mock_sql.side_effect = CartoException
carto = CartoDBTableFactory()
response = self._run_update(carto.pk)
self._run_update(carto.pk)
# self._assert_response(response, [])

def test_add(self):
Expand Down Expand Up @@ -523,7 +523,8 @@ def test_remap_table_invalid(self):
def test_validate_remap_table(self):
""" """
self.mock_sql.return_value = {
"rows": [{
"rows": [
{
"the_geom": "Point(20 20)",
"name": "New Location",
"pcode": "123",
Expand All @@ -540,4 +541,4 @@ def test_validate_remap_table(self):
LocationFactory(p_code="123", gateway=carto.location_type)
LocationFactory(p_code="456", gateway=carto.location_type)

response = self._run_update(carto.pk)
self._run_update(carto.pk)
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{36}-d{110,111,20}
envlist = py{36}-d{110,111,20,21}
envtmpdir={toxinidir}/build/{envname}/tmp
envlogdir={toxinidir}/build/{envname}/log

Expand Down Expand Up @@ -32,6 +32,7 @@ deps =
d110: django>=1.10,<1.11
d111: django>=1.11,<1.12
d20: django>=2.0,<2.1
d21: django>=2.1,<2.2
dev: git+git://github.com/django/django.git#egg=django

whitelist_externals = createdb
Expand Down

0 comments on commit bda56a1

Please sign in to comment.