Пример #1
0
 def all(self):
     client = CkanClient(base_location=self.options.api_url,
                         api_key=self.options.api_key,
                         http_user=self.options.username,
                         http_pass=self.options.password)
     change_licenses = ChangeLicenses(client, dry_run=self.options.dry_run, force=self.options.force)
     change_licenses.change_all_packages(self.options.license_id)
Пример #2
0
 def oct10(self):
     client = CkanClient(base_location=self.options.api_url,
                         api_key=self.options.api_key)
     change_licenses = ChangeLicenses(client,
                                      dry_run=self.options.dry_run,
                                      force=self.options.force)
     change_licenses.change_oct_2010(self.options.license_id)
Пример #3
0
 def all(self):
     client = CkanClient(base_location=self.options.api_url,
                         api_key=self.options.api_key,
                         http_user=self.options.username,
                         http_pass=self.options.password)
     change_licenses = ChangeLicenses(client,
                                      dry_run=self.options.dry_run,
                                      force=self.options.force)
     change_licenses.change_all_packages(self.options.license_id)
Пример #4
0
    def test_1_change_all_pkgs(self):
        if 'sqlite' in config.get('sqlalchemy.url'):
            # Ian thinks this failed for him due to a timestamp not being converted
            # to a datetime object, and being left as a unicode object.
            # Could also be related to Sqlalchemy 0.7.x.
            raise SkipTest

        licenses_before = self.get_licenses()
        self.license_id = 'test-license'
        self.change_licenses = ChangeLicenses(self.testclient)
        self.change_licenses.change_all_packages(self.license_id)
        licenses_after = self.get_licenses()

        change_in_packages = set(licenses_before.keys()) - set(licenses_after.keys())
        assert not change_in_packages, change_in_packages
        for pkg_name in licenses_after.keys():
            assert licenses_after[pkg_name] == self.license_id, licenses_after[pkg_name]
Пример #5
0
class TestChangeLicenses(TestController):
    @classmethod
    def setup_class(self):
        # create test data
        CreateTestData.create()
        username = '******'
        user = model.User.by_name(unicode(username))
        assert user
        self.testclient = WsgiCkanClient(self.app, api_key=user.apikey, base_location='/api/2')

    @classmethod
    def teardown_class(cls):
        model.Session.remove()
        model.repo.rebuild_db()

    def get_licenses(self):
        q = model.Session.query(model.Package)
        return dict([(pkg.name, pkg.license_id) for pkg in q.all()])

    def test_1_change_all_pkgs(self):
        # Skip this test until the mock data reflects the new permission model
        # (each dataset *needs* to belong to a group
        raise SkipTest, 'Skip until mock data reflects new permission model'

        if 'sqlite' in config.get('sqlalchemy.url'):
            # Ian thinks this failed for him due to a timestamp not being converted
            # to a datetime object, and being left as a unicode object.
            # Could also be related to Sqlalchemy 0.7.x.
            raise SkipTest

        licenses_before = self.get_licenses()
        self.license_id = 'test-license'
        self.change_licenses = ChangeLicenses(self.testclient)
        self.change_licenses.change_all_packages(self.license_id)
        licenses_after = self.get_licenses()

        change_in_packages = set(licenses_before.keys()) - set(licenses_after.keys())
        assert not change_in_packages, change_in_packages
        for pkg_name in licenses_after.keys():
            assert licenses_after[pkg_name] == self.license_id, licenses_after[pkg_name]

    def test_2_test_change_oct_2010(self):
        # TODO
        pass
Пример #6
0
    def test_1_change_all_pkgs(self):
        # Skip this test until the mock data reflects the new permission model
        # (each dataset *needs* to belong to a group
        raise SkipTest, 'Skip until mock data reflects new permission model'

        if 'sqlite' in config.get('sqlalchemy.url'):
            # Ian thinks this failed for him due to a timestamp not being converted
            # to a datetime object, and being left as a unicode object.
            # Could also be related to Sqlalchemy 0.7.x.
            raise SkipTest

        licenses_before = self.get_licenses()
        self.license_id = 'test-license'
        self.change_licenses = ChangeLicenses(self.testclient)
        self.change_licenses.change_all_packages(self.license_id)
        licenses_after = self.get_licenses()

        change_in_packages = set(licenses_before.keys()) - set(licenses_after.keys())
        assert not change_in_packages, change_in_packages
        for pkg_name in licenses_after.keys():
            assert licenses_after[pkg_name] == self.license_id, licenses_after[pkg_name]
Пример #7
0
 def oct10(self):
     client = CkanClient(base_location=self.options.api_url,
                         api_key=self.options.api_key)
     change_licenses = ChangeLicenses(client, dry_run=self.options.dry_run, force=self.options.force)
     change_licenses.change_oct_2010(self.options.license_id)