-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from unicef/staging
Staging
- Loading branch information
Showing
39 changed files
with
863 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.10 on 2016-10-27 17:22 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
import django.db.models.manager | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('locations', '0006_auto_20160229_1545'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelManagers( | ||
name='cartodbtable', | ||
managers=[ | ||
('_default_manager', django.db.models.manager.Manager()), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,50 @@ | ||
__author__ = 'achamseddine' | ||
|
||
from django.db import connection | ||
from django.core.cache import cache | ||
from rest_framework import status | ||
|
||
from EquiTrack.factories import UserFactory | ||
from EquiTrack.factories import UserFactory, LocationFactory | ||
from EquiTrack.tests.mixins import APITenantTestCase | ||
from locations.models import Location | ||
|
||
|
||
class TestLocationViews(APITenantTestCase): | ||
|
||
def setUp(self): | ||
self.unicef_staff = UserFactory(is_staff=True) | ||
self.locations = [LocationFactory() for x in xrange(5)] | ||
|
||
def test_api_locationtypes_list(self): | ||
response = self.forced_auth_req('get', '/api/locations-types/', user=self.unicef_staff) | ||
|
||
self.assertEquals(response.status_code, status.HTTP_200_OK) | ||
|
||
# def test_api_location_detail(self): | ||
# response = self.forced_auth_req('get', '/api/locations/454545/', user=self.unicef_staff) | ||
# | ||
# self.assertEquals(response.status_code, status.HTTP_200_OK) | ||
def test_api_location_list_cached(self): | ||
response = self.forced_auth_req('get', '/api/locations/', user=self.unicef_staff) | ||
self.assertEquals(response.status_code, status.HTTP_200_OK) | ||
self.assertEquals(len(response.data), 5) | ||
etag = response["ETag"] | ||
|
||
response = self.forced_auth_req('get', '/api/locations/', user=self.unicef_staff, HTTP_IF_NONE_MATCH=etag) | ||
self.assertEquals(response.status_code, status.HTTP_304_NOT_MODIFIED) | ||
|
||
def test_api_location_list_modified(self): | ||
response = self.forced_auth_req('get', '/api/locations/', user=self.unicef_staff) | ||
self.assertEquals(response.status_code, status.HTTP_200_OK) | ||
self.assertEquals(len(response.data), 5) | ||
etag = response["ETag"] | ||
|
||
location = LocationFactory() | ||
|
||
response = self.forced_auth_req('get', '/api/locations/', user=self.unicef_staff, HTTP_IF_NONE_MATCH=etag) | ||
self.assertEquals(response.status_code, status.HTTP_200_OK) | ||
self.assertEquals(len(response.data), 6) | ||
|
||
def test_location_delete_etag(self): | ||
# Activate cache-aside with a request. | ||
response = self.forced_auth_req('get', '/api/locations/', user=self.unicef_staff) | ||
schema_name = connection.schema_name | ||
etag_before = cache.get("{}-locations-etag".format(schema_name)) | ||
Location.objects.all().delete() | ||
etag_after = cache.get("{}-locations-etag".format(schema_name)) | ||
assert etag_before != etag_after |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.10 on 2016-10-27 17:22 | ||
from __future__ import unicode_literals | ||
|
||
import django.contrib.postgres.fields.jsonb | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('partners', '0073_governmentinterventionresult_planned_visits'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='distributionplan', | ||
name='document', | ||
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='indicatorreport', | ||
name='disaggregation', | ||
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict), | ||
), | ||
migrations.AlterField( | ||
model_name='partnerorganization', | ||
name='hact_values', | ||
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default={}, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='resultchain', | ||
name='disaggregation', | ||
field=django.contrib.postgres.fields.jsonb.JSONField(null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.