Skip to content

Commit

Permalink
[#2733] Update basic delete test: make sure table
Browse files Browse the repository at this point in the history
has actually been deleted.
  • Loading branch information
johnglover committed Jul 30, 2012
1 parent 5daba25 commit 7e31f90
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ckanext/datastore/tests/test_datastore.py
@@ -1,4 +1,5 @@
import json
import sqlalchemy
import ckan.plugins as p
import ckan.lib.create_test_data as ctd
import ckan.model as model
Expand Down Expand Up @@ -357,11 +358,23 @@ def setup(self):
assert res_dict['success'] is True

def test_delete_basic(self):
data = {'resource_id': self.data['resource_id']}
id = self.data['resource_id']
data = {'resource_id': id}
postparams = '%s=1' % json.dumps(data)
auth = {'Authorization': str(self.sysadmin_user.apikey)}
res = self.app.post('/api/action/datastore_delete', params=postparams,
extra_environ=auth)
res_dict = json.loads(res.body)
assert res_dict['success'] is True
assert res_dict['result'] == data

c = model.Session.connection()

try:
# check that data was actually deleted: this should raise a
# ProgrammingError as the table should not exist any more
c.execute('select * from "{0}";'.format(id))
raise Exception("Data not deleted")
except sqlalchemy.exc.ProgrammingError as e:
expected_msg = 'relation "{}" does not exist'.format(id)
assert expected_msg in str(e)

0 comments on commit 7e31f90

Please sign in to comment.