• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

qld-gov-au / ckan / 7d3c4be2-c9b2-407a-b59d-8c74d21d4cd3

23 Jan 2026 12:55AM UTC coverage: 87.882% (-0.01%) from 87.895%
7d3c4be2-c9b2-407a-b59d-8c74d21d4cd3

Pull #239

circleci

ThrawnCA
[QOLSVC-12515] apply ARIA labels to distinguish facet 'nav' from main
Pull Request #239: QOLSVC-12515 alphabetical facet sort

12 of 37 new or added lines in 2 files covered. (32.43%)

6213 existing lines in 235 files now uncovered.

47246 of 53761 relevant lines covered (87.88%)

2.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/ckanext/example_iresourcecontroller/tests/test_example_iresourcecontroller.py
1
# encoding: utf-8
2

3
"""Tests for the ckanext.example_iauthfunctions extension.
4

5
"""
6
import pytest
4✔
7

8
import ckan.plugins
4✔
9
import ckan.tests.factories as factories
4✔
10
import ckan.tests.helpers as helpers
4✔
11

12

13
@pytest.mark.ckan_config("ckan.plugins", "example_iresourcecontroller")
4✔
14
@pytest.mark.usefixtures("non_clean_db", "with_plugins")
4✔
15
class TestExampleIResourceController(object):
4✔
16
    """Tests for the plugin that uses IResourceController.
17

18
    """
19

20
    def test_resource_controller_plugin_create(self):
4✔
21
        user = factories.Sysadmin()
1✔
22
        package = factories.Dataset(user=user)
1✔
23

24
        plugin = ckan.plugins.get_plugin("example_iresourcecontroller")
1✔
25

26
        helpers.call_action(
1✔
27
            "resource_create",
28
            package_id=package["id"],
29
            name="test-resource",
30
            url="http://resource.create/",
31
            apikey=user["apikey"],
32
        )
33

34
        assert plugin.counter["before_resource_create"] == 1, plugin.counter
1✔
35
        assert plugin.counter["after_resource_create"] == 1, plugin.counter
1✔
36
        assert plugin.counter["before_resource_update"] == 0, plugin.counter
1✔
37
        assert plugin.counter["after_resource_update"] == 0, plugin.counter
1✔
38
        assert plugin.counter["before_resource_delete"] == 0, plugin.counter
1✔
39
        assert plugin.counter["after_resource_delete"] == 0, plugin.counter
1✔
40

41
    def test_resource_controller_plugin_update(self):
4✔
UNCOV
42
        user = factories.Sysadmin()
1✔
UNCOV
43
        resource = factories.Resource(user=user)
1✔
UNCOV
44
        plugin = ckan.plugins.get_plugin("example_iresourcecontroller")
1✔
45

UNCOV
46
        helpers.call_action(
1✔
47
            "resource_update",
48
            id=resource["id"],
49
            url="http://resource.updated/",
50
            apikey=user["apikey"],
51
        )
52

UNCOV
53
        assert plugin.counter["before_resource_create"] == 1, plugin.counter
1✔
UNCOV
54
        assert plugin.counter["after_resource_create"] == 1, plugin.counter
1✔
UNCOV
55
        assert plugin.counter["before_resource_update"] == 1, plugin.counter
1✔
UNCOV
56
        assert plugin.counter["after_resource_update"] == 1, plugin.counter
1✔
UNCOV
57
        assert plugin.counter["before_resource_delete"] == 0, plugin.counter
1✔
UNCOV
58
        assert plugin.counter["after_resource_delete"] == 0, plugin.counter
1✔
59

60
    def test_resource_controller_plugin_delete(self):
4✔
UNCOV
61
        user = factories.Sysadmin()
1✔
UNCOV
62
        resource = factories.Resource(user=user)
1✔
63

UNCOV
64
        plugin = ckan.plugins.get_plugin("example_iresourcecontroller")
1✔
65

UNCOV
66
        helpers.call_action(
1✔
67
            "resource_delete", id=resource["id"], apikey=user["apikey"]
68
        )
69

UNCOV
70
        assert plugin.counter["before_resource_create"] == 1, plugin.counter
1✔
UNCOV
71
        assert plugin.counter["after_resource_create"] == 1, plugin.counter
1✔
UNCOV
72
        assert plugin.counter["before_resource_update"] == 0, plugin.counter
1✔
UNCOV
73
        assert plugin.counter["after_resource_update"] == 0, plugin.counter
1✔
UNCOV
74
        assert plugin.counter["before_resource_delete"] == 1, plugin.counter
1✔
UNCOV
75
        assert plugin.counter["after_resource_delete"] == 1, plugin.counter
1✔
76

77
    def test_resource_controller_plugin_show(self):
4✔
78
        """
79
        Before show gets called by the other methods but we test it
80
        separately here and make sure that it doesn't call the other
81
        methods.
82
        """
UNCOV
83
        user = factories.Sysadmin()
1✔
UNCOV
84
        package = factories.Dataset(user=user)
1✔
UNCOV
85
        factories.Resource(user=user, package_id=package["id"])
1✔
86

UNCOV
87
        plugin = ckan.plugins.get_plugin("example_iresourcecontroller")
1✔
88

UNCOV
89
        helpers.call_action("package_show", name_or_id=package["id"])
1✔
90

UNCOV
91
        assert plugin.counter["before_resource_create"] == 1, plugin.counter
1✔
UNCOV
92
        assert plugin.counter["after_resource_create"] == 1, plugin.counter
1✔
UNCOV
93
        assert plugin.counter["before_resource_update"] == 0, plugin.counter
1✔
UNCOV
94
        assert plugin.counter["after_resource_update"] == 0, plugin.counter
1✔
UNCOV
95
        assert plugin.counter["before_resource_delete"] == 0, plugin.counter
1✔
UNCOV
96
        assert plugin.counter["after_resource_delete"] == 0, plugin.counter
1✔
UNCOV
97
        assert plugin.counter["before_resource_show"] == 4, plugin.counter
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc