Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky datapusher test #6537

Open
amercader opened this issue Nov 12, 2021 · 1 comment
Open

Flaky datapusher test #6537

amercader opened this issue Nov 12, 2021 · 1 comment
Assignees

Comments

@amercader
Copy link
Member

amercader commented Nov 12, 2021

These tests keeps failing from time to time in master, would be good to refactor it to avoid unrelated failures:

test_submit_when_url_changes - ckanext.datapusher.tests.test_action.TestSubmit

self = <ckanext.datapusher.tests.test_action.TestSubmit object at 0x7fe284e0a050>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fe285d08c10>

    @pytest.mark.ckan_config("ckan.views.default_views", "")
    def test_submit_when_url_changes(self, monkeypatch):
        dataset = factories.Dataset()
        func = mock.Mock()
        monkeypatch.setitem(_actions, 'datapusher_submit', func)
    
        resource = helpers.call_action(
            "resource_create",
            {},
            package_id=dataset["id"],
            url="http://example.com/file.pdf",
        )
    
        func.assert_not_called()
    
        helpers.call_action(
            "resource_update",
            {},
            id=resource["id"],
            package_id=dataset["id"],
            url="http://example.com/file.csv",
            format="CSV",
        )
    
>       func.assert_called()

ckanext/datapusher/tests/test_action.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

_mock_self = <Mock id='140610869027856'>

    def assert_called(_mock_self):
        """assert that the mock was called at least once
        """
        self = _mock_self
        if self.call_count == 0:
            msg = ("Expected '%s' to have been called." %
                   self._mock_name or 'mock')
>           raise AssertionError(msg)
E           AssertionError: Expected 'None' to have been called.

/usr/local/lib/python3.7/unittest/mock.py:850: AssertionError

Another one:

test_search_page_results - ckan.tests.controllers.test_package.TestSearch

self = <ckan.tests.controllers.test_package.TestSearch object at 0x7fa5e0a579d0>
app = <ckan.tests.helpers.CKANTestApp object at 0x7fa5e03f18d0>

    def test_search_page_results(self, app):
        """Searching for datasets returns expected results."""
    
        factories.Dataset(name="dataset-one", title="Dataset One")
        factories.Dataset(name="dataset-two", title="Dataset Two")
        factories.Dataset(name="dataset-three", title="Dataset Three")
    
        search_url = url_for("dataset.search")
        search_results = app.get(search_url, query_string={'q': 'One'})
    
>       assert "1 dataset found" in search_results
E       AssertionError: assert '1 dataset found' in <WrapperTestResponse 16009 bytes [200 OK]>

ckan/tests/controllers/test_package.py:1646: AssertionError
@smotornyuk
Copy link
Member

smotornyuk commented Nov 12, 2021

I've also noticed them. The one from datapusher acidentally fails for few months, I believe

I'll try to work on it next week. I'm testing the execution of tests in random order and such flaky tests are exactly what I'm looking for

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants