Skip to content

Fix issue 375 #2#1167

Merged
berkerpeksag merged 5 commits intopython:masterfrom
CianciuStyles:fix-issue-375-2
Nov 21, 2017
Merged

Fix issue 375 #2#1167
berkerpeksag merged 5 commits intopython:masterfrom
CianciuStyles:fix-issue-375-2

Conversation

@CianciuStyles
Copy link
Copy Markdown
Contributor

Hello,

I'm sorry this took so long. I am opening a new pull request for closing issue #375, in which I addressed the approach we discussed in the other PR (#1161).

I have also added a test for issue #560, so hopefully this should fix that as well.

Copy link
Copy Markdown
Member

@berkerpeksag berkerpeksag left a comment

Choose a reason for hiding this comment

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

Could you also rename 0006_auto_20171029_1524.py to a more readable name so we can easily see that it's a data migration?

Comment thread blogs/tests/test_parser.py Outdated
super().setUpClass()
cls.test_file_path = get_test_rss_path()
cls.entries = get_all_entries("file://{}".format(cls.test_file_path))
cls.entries = get_all_entries("file:///{}".format(cls.test_file_path))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you get a test failure without this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I do indeed...

Traceback (most recent call last):
  File "C:\Users\cianciustyles\Documents\Code\Python.org\blogs\tests\test_parser.py", line 17, in test_entries
    self.assertEqual(len(self.entries), 25)
AssertionError: 0 != 25

but I can completely drop the first commit with the changes to make the tests pass on my host, if this already works for you.

]

operations = [
migrations.RunPython(exclude_ending_day, include_ending_day)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Style nit: Please add trailing comma.

Comment thread events/tests/test_importer.py Outdated
def test_injest(self):
importer = ICSImporter(self.calendar)
with open(EVENTS_CALENDAR) as fh:
with open(EVENTS_CALENDAR, encoding='utf-8') as fh:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This shouldn't be necessary. What's the output of the following command in your system?

locale.getpreferredencoding(False)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

On my Windows 10 laptop, the result is the following:

>>> import locale
>>> locale.getpreferredencoding(False)
'cp1252'

As in a previous comment, I think it would be better for the time being to drop completely these changes, and only commit the ones about the event importer with tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've never tried to run python.org tests under Windows so feel free to send those changes as a separate PR :)

e.next_or_previous_time.dt_end
)

ical = """\
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we move the new tests to separate test methods?

Comment thread events/tests/test_importer.py Outdated
make_aware(datetime(year=2013, month=8, day=2, hour=20, minute=30)),
e4.next_or_previous_time.dt_end
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Style nit: Please delete the extra line.

Comment thread peps/converters.py Outdated
"""
pep0_path = os.path.join(settings.PEP_REPO_PATH, 'pep-0000.html')
pep0_content = open(pep0_path).read()
pep0_content = open(pep0_path, encoding="utf-8 ").read()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this change is in scope of #375.

from django.db import migrations


def exclude_ending_day(apps, _):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd replace _ with schema_editor and use it in:

...
db_alias = schema_editor.connection.alias
...
Model.objects.using(db_alias).filter(...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was not aware this was possible, I'm happy to change it.


def exclude_ending_day(apps, _):
OccurringRule = apps.get_model('events', 'OccurringRule')
for occurring_rule in OccurringRule.objects.filter(all_day=True):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't we do this without a for loop?

from django.db.models import F

OccurringRule.objects.filter(all_day=True).update(dt_end=F('dt_end') - datetime.timedelta(days=1))

@berkerpeksag berkerpeksag mentioned this pull request Nov 1, 2017
@CianciuStyles
Copy link
Copy Markdown
Contributor Author

I think I have addressed all the changes you requested. If I forgot anything or some more changes are required, just let me know!

@berkerpeksag berkerpeksag merged commit 5d27916 into python:master Nov 21, 2017
@CianciuStyles CianciuStyles deleted the fix-issue-375-2 branch November 21, 2017 14:13
@berkerpeksag
Copy link
Copy Markdown
Member

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants