Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Improvement: if the Debug true disable the verify ssl in fetch content, That form is better to run local, I think :) #27

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

elinaldosoft
Copy link

In my case it was giving error.

@elinaldosoft
Copy link
Author

The .env that is use for CI, is the same as for local development?

Copy link
Collaborator

@cuducos cuducos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for the contribution @elinaldosoft! I think you code have some issues, so I added minor inline comments to highlight what I think is important to be reviewed before we merge, ok?

victims/data.py Outdated
if DEBUG:
session = aiohttp.ClientSession(
connector=aiohttp.TCPConnector(verify_ssl=False)
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not the proper place to handle this kwarg. The session is defined a few lines above and you're overwriting it. Beyond that now there's two different places defining sessions for the same request, what is a bit confusing. I'm gonna suggest something different around line 40;

     async def fetch_spreadsheets(self):
        urls = (…)
        kwargs = {'loop': asyncio.get_event_loop()}
        if DEBUG:
            kwargs = {'connector': aiohttp.TCPConnector(verify_ssl=False)}
        
        async with aiohttp.ClientSession(**kwargs) as session:
            …

@@ -22,7 +22,7 @@
</div><!-- end .meta -->

<h2>
<a class="no-underline" href="{{ case.main_story.url }}">{{ case.main_story.title|e }}</a>
<a class="no-underline" href="{{ case.main_story.url }}" target="_blank">{{ case.main_story.title|e }}</a>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't belong in this PR. Please, check #9.

data = Data()
loop = asyncio.get_event_loop()
cases = loop.run_until_complete(data.cases())
assert len(cases) == 3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not advisable. It makes tests depends on external connection and availability, and it also depends on envvar settings (have you seen it's failing on Travis? We use the production stylesheet there, probably that's why it's failing).

@elinaldosoft
Copy link
Author

What would be the way to test the session (verify_ssl=false) of request?

@cuducos
Copy link
Collaborator

cuducos commented Oct 15, 2018

We need two mocks I guess:

  • We need to mock settings.DEBUG to make sure we run tests without debug mode even if the envvar says DEBUG=True
  • We need to mock aiohttp.Session to assert it was called with the expect keyword

@cuducos cuducos mentioned this pull request Jun 19, 2019
@sergiomario
Copy link
Collaborator

@elinaldosoft We still have a review item to complete in this PR. Do you need any help?

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

Successfully merging this pull request may close these issues.

None yet

3 participants