|
| 1 | +import pytest |
| 2 | + |
| 3 | +from ckan.tests.factories import Organization |
| 4 | +from ckanext.recombinant.tests import RecombinantTestBase |
| 5 | + |
| 6 | +from ckanapi import LocalCKAN |
| 7 | +from ckan.plugins.toolkit import config, ObjectNotFound |
| 8 | +from ckanext.recombinant.tables import _get_plugin |
| 9 | +from ckanext.recombinant.logic import _action_get_dataset |
| 10 | + |
| 11 | + |
| 12 | +class TestRecombinantLogic(RecombinantTestBase): |
| 13 | + @classmethod |
| 14 | + def setup_method(self, method): |
| 15 | + """Method is called at class level before EACH test methods of the class are called. |
| 16 | + Setup any state specific to the execution of the given class methods. |
| 17 | + """ |
| 18 | + super(TestRecombinantLogic, self).setup_method(method) |
| 19 | + |
| 20 | + self.lc = LocalCKAN() |
| 21 | + |
| 22 | + def test_deleted_org(self): |
| 23 | + """ |
| 24 | + Deleted orgs should not show Recombinant. |
| 25 | + """ |
| 26 | + org = Organization() |
| 27 | + _get_plugin().update_config(config) |
| 28 | + self.lc.action.recombinant_create(dataset_type='sample', |
| 29 | + owner_org=org['name']) |
| 30 | + _lc, _geno, dataset = _action_get_dataset({'ignore_auth': True}, |
| 31 | + {'dataset_type': 'sample', |
| 32 | + 'owner_org': org['name']}) |
| 33 | + self.lc.action.package_delete(id=dataset['id']) |
| 34 | + self.lc.action.organization_delete(id=org['id']) |
| 35 | + with pytest.raises(ObjectNotFound): |
| 36 | + self.lc.action.recombinant_show(dataset_type='sample', |
| 37 | + owner_org=org['name']) |
0 commit comments