Skip to content

Commit

Permalink
fix(tests): implement;
Browse files Browse the repository at this point in the history
- Add `IPipeValidation` implementation into test class.
  • Loading branch information
JVickery-TBS committed Jul 23, 2024
1 parent 9d7dba2 commit 4610232
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ckanext/validation/tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
class TestPlugin(p.SingletonPlugin):

p.implements(IDataValidation, inherit=True)
p.implements(IPipeValidation, inherit=True)

calls = 0

def reset_counter(self):
self.calls = 0

# IDataValidation

def can_validate(self, context, data_dict):
self.calls += 1

Expand All @@ -36,6 +39,11 @@ def set_update_mode(self, context, data_dict, current_mode):
is_async = data_dict.get('async')
return settings.ASYNC_MODE if is_async else current_mode

# IPipeValidation

def receive_validation_report(self, validation_report):
self.calls += 1


def _get_data_plugin_calls():
for plugin in p.PluginImplementations(IDataValidation):
Expand All @@ -53,6 +61,9 @@ def setup(self):
for plugin in p.PluginImplementations(IDataValidation):
return plugin.reset_counter()

for plugin in p.PluginImplementations(IPipeValidation):
return plugin.reset_counter()


@pytest.mark.usefixtures("clean_db", "validation_setup")
@mock.patch(helpers.MOCK_SYNC_VALIDATE, return_value=helpers.VALID_REPORT)
Expand Down

0 comments on commit 4610232

Please sign in to comment.