Skip to content

Commit

Permalink
[#2856] Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Mar 30, 2016
1 parent d4fc959 commit b295b91
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions ckanext/datastore/tests/test_create.py
Expand Up @@ -189,6 +189,47 @@ def _execute_sql(self, sql, *args):
session = orm.scoped_session(orm.sessionmaker(bind=engine))
return session.connection().execute(sql, *args)

def test_sets_datastore_active_on_resource_on_create(self):
resource = factories.Resource()

assert_equal(resource['datastore_active'], False)

data = {
'resource_id': resource['id'],
'force': True,
'records': [
{'book': 'annakarenina', 'author': 'tolstoy'}
]
}

helpers.call_action('datastore_create', **data)

resource = helpers.call_action('resource_show', id=resource['id'])

assert_equal(resource['datastore_active'], True)

def test_sets_datastore_active_on_resource_on_delete(self):
resource = factories.Resource(datastore_active=True)

assert_equal(resource['datastore_active'], True)

data = {
'resource_id': resource['id'],
'force': True,
'records': [
{'book': 'annakarenina', 'author': 'tolstoy'}
]
}

helpers.call_action('datastore_create', **data)

helpers.call_action('datastore_delete', resource_id=resource['id'],
force=True)

resource = helpers.call_action('resource_show', id=resource['id'])

assert_equal(resource['datastore_active'], False)


class TestDatastoreCreate(tests.WsgiAppCase):
sysadmin_user = None
Expand Down

0 comments on commit b295b91

Please sign in to comment.