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

page_cache not working in test_missing_pre_or_code_query #428

Open
ykskks opened this issue Sep 23, 2021 · 3 comments
Open

page_cache not working in test_missing_pre_or_code_query #428

ykskks opened this issue Sep 23, 2021 · 3 comments
Labels

Comments

@ykskks
Copy link
Contributor

ykskks commented Sep 23, 2021

What happened:

Fork and clone the repository to local. I ran the test with python3 -m test_howdoi. I get the following result.

Traceback (most recent call last):
  File "/Users/XXX/Projects/howdoi/test_howdoi.py", line 270, in test_missing_pre_or_code_query
    self.assertIn('XML elements present in a XML', output)
AssertionError: 'XML elements present in a XML' not found in '<people>\n    <student>\n        <name>John</name>\n    </student>\n</people>\n'

What you expected to happen:

If the page_cache was working, the test should pass.
However, for some reason, it is not using page_cache and fetching the latest answer from stackoverflow, which has different order compared to cached_html, resulting in test failure.

@ykskks ykskks added the bug label Sep 23, 2021
@gleitz
Copy link
Owner

gleitz commented Sep 24, 2021

I believe the issue is that we are not properly patching the _get_result function during tests.

If you put print statements in the mocked function and also within the original _get_result call you will see this.

Run python -m nose test_howdoi:HowdoiTestCase.test_missing_pre_or_code_query and you'll see that the first time _get_result is called for the Google search it will use the page_cache, but the second time when we call it for the Stack Overflow answer the mocked function is not used.

My guess is that something about how we mock the function is not correct.

@gleitz
Copy link
Owner

gleitz commented Oct 25, 2021

We may want to go back to the old way of mocking the function

71c6809#diff-9484a47cc2a1a27c6407e851130f059966530293a60a4093e0c2868fe6974206L55

@alirazacodes
Copy link

Resolved the duckduckgo not found issue in the test_howdoi.py file by updating the old pacakges of duckduckgo to duckduckpy and now the duckduckgo issue in the testing file is gone, still having issue with the XML file like some parameters are being missing...

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

No branches or pull requests

3 participants