Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jul 31, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from martingaldeca July 31, 2023 20:31
Comment on lines -105 to +118
if response.status_code == 200:
logging.info(f'Day report obtained for {day.isoformat()}')
day_report = json.loads(response.content.decode())
for report in day_report:
if response.status_code != 200:
raise Exception(f'Day {day.isoformat()} problem.')
logging.info(f'Day report obtained for {day.isoformat()}')
day_report = json.loads(response.content.decode())
for report in day_report:

# TODO in the future calculate the reported time and optimize the reports
date_reported = report['date']
date_reported = f'{date_reported[6:]}-{date_reported[3:5]}-{date_reported[:2]}'
if report.get('tasks') and date_reported not in self.reported_days:
self.reported_days.append(date_reported)
logging.info(f'Day {date_reported} was previously reported')
# TODO in the future calculate the reported time and optimize the reports
date_reported = report['date']
date_reported = f'{date_reported[6:]}-{date_reported[3:5]}-{date_reported[:2]}'
if report.get('tasks') and date_reported not in self.reported_days:
self.reported_days.append(date_reported)
logging.info(f'Day {date_reported} was previously reported')

self.reported_days = list(set(self.reported_days))

else:
raise Exception(f'Day {day.isoformat()} problem.')
self.reported_days = list(set(self.reported_days))
Copy link
Author

Choose a reason for hiding this comment

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

Function WorkmeterClient.check_day_reporting refactored with the following changes:

Comment on lines -139 to +148
if response.status_code == 200:
logging.info(f'Calendar obtained for year {year}')
calendar = json.loads(response.content.decode())
for day in calendar:
if (
(expected_day := day['date'][:10]) and
until.isoformat() >= expected_day >= self.start_day.isoformat() and
expected_day not in self.holidays and
(expected_minutes := day.get('expected'))
):
self.expected_days[day['date'][:10]] = expected_minutes
else:
if response.status_code != 200:
raise Exception(f'Error obtaining calendar for year "{year}".')
logging.info(f'Calendar obtained for year {year}')
calendar = json.loads(response.content.decode())
for day in calendar:
if (
(expected_day := day['date'][:10]) and
until.isoformat() >= expected_day >= self.start_day.isoformat() and
expected_day not in self.holidays and
(expected_minutes := day.get('expected'))
):
self.expected_days[day['date'][:10]] = expected_minutes
Copy link
Author

Choose a reason for hiding this comment

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

Function WorkmeterClient.get_expected_calendar refactored with the following changes:

client.login(username=self.username, password=self.password)
self.assertEqual(client.token, 'test_token')
self.assertEqual(client.headers['Authorization'], f'Bearer test_token')
self.assertEqual(client.headers['Authorization'], 'Bearer test_token')
Copy link
Author

Choose a reason for hiding this comment

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

Function ClientTest.test_login refactored with the following changes:

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.

0 participants