Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
Rename plugin field to plugin_name
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Dec 1, 2016
1 parent 5459ed6 commit 0825972
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions goodtablesio/helpers/create.py
Expand Up @@ -46,10 +46,10 @@ def create_job(validation_conf, job_id=None):
return job_id


def insert_job_row(job_id, plugin='api', plugin_conf=None):
def insert_job_row(job_id, plugin_name='api', plugin_conf=None):
row = {
'job_id': job_id,
'plugin': plugin,
'plugin_name': plugin_name,
'plugin_conf': plugin_conf,
'created': datetime.datetime.utcnow(),
'status': 'created',
Expand Down
4 changes: 2 additions & 2 deletions goodtablesio/models.py
Expand Up @@ -6,7 +6,7 @@ class Job():

job_id = None
status = 'created'
plugin = 'api'
plugin_name = 'api'
plugin_conf = None
created = None
finished = None
Expand All @@ -15,7 +15,7 @@ class Job():
def __init__(self, *args, **kwargs):
self.job_id = kwargs.get('job_id')
self.status = kwargs.get('status', 'created')
self.plugin = kwargs.get('plugin', 'api')
self.plugin_name = kwargs.get('plugin_name', 'api')
self.plugin_conf = kwargs.get('plugin_conf')
self.created = kwargs.get('created')
self.finished = kwargs.get('finished')
Expand Down
8 changes: 5 additions & 3 deletions goodtablesio/plugins/github/tasks.py
Expand Up @@ -46,7 +46,7 @@ def post_task_handler(**kwargs):

job = kwargs['retval']

if job.get('plugin') != 'github':
if job.get('plugin_name') != 'github':
return

task_state = kwargs['state']
Expand Down Expand Up @@ -93,8 +93,10 @@ def _get_job_conf_url(clone_url, branch='master'):
match = re.search(pattern, clone_url)
user = match.group('user')
repo = match.group('repo')
template = 'https://raw.githubusercontent.com/{user}/{repo}/{branch}/goodtables.yml'
job_conf = template.format(user=user, repo=repo, branch=branch)
template = '/{user}/{repo}/{branch}/goodtables.yml'
job_conf = template.format(
base='https://raw.githubusercontent.com',
user=user, repo=repo, branch=branch)
return job_conf


Expand Down
4 changes: 0 additions & 4 deletions goodtablesio/services.py
@@ -1,5 +1,4 @@
import dataset
from sqlalchemy.dialects.postgresql import JSONB

from . import config

Expand All @@ -8,6 +7,3 @@

database = dataset.connect(config.DATABASE_URL)
database.get_table('jobs', primary_id='job_id', primary_type='String')

# TODO: get rid of this after #33
database['jobs'].create_column('plugin_conf', JSONB)
7 changes: 4 additions & 3 deletions goodtablesio/tests/factories.py
Expand Up @@ -18,7 +18,7 @@ class Meta:

job_id = factory.Sequence(lambda n: str(uuid.uuid4()))
created = factory.LazyAttribute(lambda o: datetime.datetime.utcnow())
plugin = 'api'
plugin_name = 'api'
plugin_conf = None
status = 'created'
finished = None
Expand All @@ -28,14 +28,15 @@ class Meta:
def _create(cls, model_class, *args, **kwargs):

row = {}
for field in ('job_id', 'plugin', 'plugin_conf',
for field in ('job_id', 'plugin_name', 'plugin_conf',
'created', 'finished', 'report', 'status'):
row[field] = kwargs.get(field)

services.database['jobs'].insert(row,
types={'created': DateTime,
'finished': DateTime,
'report': JSONB},
'report': JSONB,
'plugin_conf': JSONB},
ensure=True)

return model_class(*args, **kwargs)
4 changes: 2 additions & 2 deletions goodtablesio/tests/helpers/test_create.py
Expand Up @@ -19,7 +19,7 @@ def test_insert_job_row():

assert job['job_id'] == 'my-id'
assert job['status'] == 'created'
assert job['plugin'] == 'api'
assert job['plugin_name'] == 'api'
assert job['plugin_conf'] is None
assert job['created']

Expand All @@ -37,7 +37,7 @@ def test_insert_job_row_plugin_conf():

assert job['job_id'] == 'my-id'
assert job['status'] == 'created'
assert job['plugin'] == 'my-plugin'
assert job['plugin_name'] == 'my-plugin'
assert job['plugin_conf'] == {'some': 'conf'}
assert job['created']

Expand Down

0 comments on commit 0825972

Please sign in to comment.