Skip to content

Commit

Permalink
Change 'osType' to 'columnType'
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed Jul 17, 2018
1 parent 40dec2b commit a48c969
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM python:3.6-alpine

RUN apk add --update --no-cache libpq postgresql-dev libffi libffi-dev bash curl libstdc++ nodejs
RUN apk add --update --no-cache --virtual=build-dependencies build-base
RUN apk add --update --no-cache --virtual=build-dependencies build-base
RUN apk --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --update add leveldb leveldb-dev

WORKDIR /app
ADD requirements.txt .
RUN pip install -r requirements.txt

# Install os-types, used in the loading process for fiscal modelling the datapackage
RUN npm install -g os-types
RUN npm install -g os-types@1.15.1-alpha.1

RUN apk del build-dependencies
RUN rm -rf /var/cache/apk/*
Expand Down
6 changes: 3 additions & 3 deletions conductor/blueprints/package/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def prepare_field(field, slugs):
ret = {
'header': slug,
'aliases': aliases,
'osType': field['osType'],
'columnType': field['columnType'],
}
if 'title' in field:
ret['title'] = field['title']
ret['options'] = copy_except(field,
('name', 'title', 'osType', 'type',
('name', 'title', 'columnType', 'type',
'slug', 'conceptType', 'format'))
return ret

Expand Down Expand Up @@ -138,7 +138,7 @@ def upload(datapackage, token, cache_get, cache_set):
prepare_field(f, slugs)
for f in
r.descriptor['schema']['fields']
if 'osType' in f
if 'columnType' in f
]
}
package_id = \
Expand Down
20 changes: 15 additions & 5 deletions tests/module/blueprints/package/test_controllers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections import namedtuple
import unittest

import time
Expand All @@ -16,6 +15,8 @@

module = import_module('conductor.blueprints.package.controllers')
dpp_module = import_module('datapackage.helpers')


class Response:
def __init__(self, status_code, _json):
self.status_code = status_code
Expand All @@ -28,6 +29,7 @@ def raise_for_status(self):
if self.status_code != 200:
raise AssertionError('HTTP {}'.format(self.status_code))


datapackage = {
'name': 'my-dataset',
'resources': [
Expand All @@ -36,7 +38,9 @@ def raise_for_status(self):
'path': 'data.csv',
'schema': {
'fields': [
{'name': 'year', 'type': 'integer', 'osType': 'date:fiscal-year'}
{'name': 'year',
'type': 'integer',
'columnType': 'date:fiscal-year'}
]
}
}
Expand All @@ -47,6 +51,7 @@ def raise_for_status(self):
callback = 'http://conductor/callback'
token = None


def cache_get(key):
global _cache
return _cache.get(key)
Expand All @@ -66,7 +71,8 @@ def setUp(self):
global token

self.private_key = PRIVATE_KEY
token = jwt.encode({'userid': 'owner'}, PRIVATE_KEY, algorithm='RS256').decode('ascii')
token = jwt.encode({'userid': 'owner'},
PRIVATE_KEY, algorithm='RS256').decode('ascii')

# Cleanup
self.addCleanup(patch.stopall)
Expand Down Expand Up @@ -94,7 +100,8 @@ def assertResponse(self, ret, status=None, progress=None, error=None):
def test___load___good_request(self):
api_load = module.upload
self.requests.get = Mock(return_value=Response(200, datapackage))
self.assertResponse(api_load('http://bla', token, cache_get, cache_set), 'queued', 0)
self.assertResponse(api_load('http://bla', token,
cache_get, cache_set), 'queued', 0)

# def test___load___bad_request(self):
# api_load = module.upload
Expand All @@ -109,7 +116,10 @@ def test___load___good_request(self):
def test___callback___server_down(self):
api_load = module.upload
self.requests.get = Mock(return_value=Response(499, datapackage))
self.assertResponse(api_load('http://bla', token, cache_get, cache_set), 'fail', error='HTTP 499')
self.assertResponse(api_load('http://bla',
token,
cache_get,
cache_set), 'fail', error='HTTP 499')

def test___poll___good_request(self):
api_load = module.upload
Expand Down

0 comments on commit a48c969

Please sign in to comment.