misc: apply double-quote-string-fixer (#79866)
This commit is contained in:
parent
ebe3b7eb10
commit
b71dc670c7
|
@ -1686,7 +1686,7 @@ class TimePeriod(models.Model):
|
|||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.agenda:
|
||||
assert self.agenda.kind == 'virtual', "a time period can only reference a virtual agenda"
|
||||
assert self.agenda.kind == 'virtual', 'a time period can only reference a virtual agenda'
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@property
|
||||
|
@ -4024,7 +4024,7 @@ class SharedCustodyAgenda(models.Model):
|
|||
qs = qs.exclude(pk=instance.pk)
|
||||
|
||||
qs = qs.extra(
|
||||
where=["(date_start, date_end) OVERLAPS (%s, %s)"],
|
||||
where=['(date_start, date_end) OVERLAPS (%s, %s)'],
|
||||
params=[date_start, date_end],
|
||||
)
|
||||
return qs.exists()
|
||||
|
|
|
@ -2370,7 +2370,7 @@ class SubscriptionFilter(filters.FilterSet):
|
|||
{missing: _('This filter is required when using "%s" filter.') % not_missing}
|
||||
)
|
||||
queryset = queryset.extra(
|
||||
where=["(date_start, date_end) OVERLAPS (%s, %s)"],
|
||||
where=['(date_start, date_end) OVERLAPS (%s, %s)'],
|
||||
params=[
|
||||
self.form.cleaned_data['date_start'],
|
||||
self.form.cleaned_data['date_end'],
|
||||
|
@ -2416,7 +2416,7 @@ class SubscriptionsAPI(ListAPIView):
|
|||
agenda=self.agenda,
|
||||
user_external_id=serializer.validated_data['user_external_id'],
|
||||
).extra(
|
||||
where=["(date_start, date_end) OVERLAPS (%s, %s)"],
|
||||
where=['(date_start, date_end) OVERLAPS (%s, %s)'],
|
||||
params=[date_start, date_end],
|
||||
)
|
||||
if overlapping_subscription_qs.exists():
|
||||
|
@ -2481,7 +2481,7 @@ class SubscriptionAPI(APIView):
|
|||
)
|
||||
.exclude(pk=self.subscription.pk)
|
||||
.extra(
|
||||
where=["(date_start, date_end) OVERLAPS (%s, %s)"],
|
||||
where=['(date_start, date_end) OVERLAPS (%s, %s)'],
|
||||
params=[date_start, date_end],
|
||||
)
|
||||
)
|
||||
|
|
|
@ -414,7 +414,7 @@ class EventDuplicateForm(forms.ModelForm):
|
|||
def save(self, *args, **kwargs):
|
||||
with transaction.atomic():
|
||||
self.instance = self.instance.duplicate(
|
||||
label=self.cleaned_data["label"], start_datetime=self.cleaned_data["start_datetime"]
|
||||
label=self.cleaned_data['label'], start_datetime=self.cleaned_data['start_datetime']
|
||||
)
|
||||
if self.instance.recurrence_days:
|
||||
self.instance.create_all_recurrences()
|
||||
|
|
|
@ -264,7 +264,7 @@ class DateMixin:
|
|||
year = int(year)
|
||||
dates[year] = {}
|
||||
for week, week_label in self.get_weeks():
|
||||
date = datetime.datetime.strptime('%s-W%s-1' % (year, week), "%Y-W%W-%w")
|
||||
date = datetime.datetime.strptime('%s-W%s-1' % (year, week), '%Y-W%W-%w')
|
||||
dates[year][date] = week_label
|
||||
return dates
|
||||
|
||||
|
@ -1027,7 +1027,7 @@ class AgendasImportView(FormView):
|
|||
else:
|
||||
message2 = import_messages[obj_name]['update'](count) % {'count': count}
|
||||
|
||||
obj_results['messages'] = "%s %s" % (message1, message2)
|
||||
obj_results['messages'] = '%s %s' % (message1, message2)
|
||||
|
||||
a_count, uc_count = (
|
||||
len(results['agendas']['all']),
|
||||
|
@ -1138,7 +1138,7 @@ agenda_roles = AgendaRolesView.as_view()
|
|||
|
||||
class AgendaDisplaySettingsView(AgendaEditView):
|
||||
form_class = AgendaDisplaySettingsForm
|
||||
title = _("Configure display options")
|
||||
title = _('Configure display options')
|
||||
tab_anchor = 'display-options'
|
||||
|
||||
def set_agenda(self, **kwargs):
|
||||
|
@ -1153,7 +1153,7 @@ agenda_display_settings = AgendaDisplaySettingsView.as_view()
|
|||
|
||||
class AgendaBookingCheckSettingsView(AgendaEditView):
|
||||
form_class = AgendaBookingCheckSettingsForm
|
||||
title = _("Configure booking check options")
|
||||
title = _('Configure booking check options')
|
||||
tab_anchor = 'booking-check-options'
|
||||
|
||||
def set_agenda(self, **kwargs):
|
||||
|
@ -3070,7 +3070,7 @@ meeting_type_delete = MeetingTypeDeleteView.as_view()
|
|||
|
||||
|
||||
def process_time_period_add_form(form, desk=None, agenda=None):
|
||||
assert desk or agenda, "a time period requires a desk or a agenda"
|
||||
assert desk or agenda, 'a time period requires a desk or a agenda'
|
||||
for weekday in form.cleaned_data.get('weekdays'):
|
||||
period = TimePeriod(
|
||||
weekday=weekday,
|
||||
|
|
|
@ -57,4 +57,4 @@ class EnsureJsonbType(Operation):
|
|||
pass
|
||||
|
||||
def describe(self):
|
||||
return "Migrate to postgres jsonb type"
|
||||
return 'Migrate to postgres jsonb type'
|
||||
|
|
|
@ -11,5 +11,5 @@ import os
|
|||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chrono.settings")
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chrono.settings')
|
||||
application = get_wsgi_application()
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chrono.settings")
|
||||
if __name__ == '__main__':
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chrono.settings')
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
|
|
|
@ -1406,21 +1406,21 @@ def test_multiple_booking_api(app, user):
|
|||
app.authorization = ('Basic', ('john.doe', 'password'))
|
||||
resp = app.post('/api/agenda/%s/fillslot/%s/?count=NaN' % (agenda.slug, event.id), status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['reason'] == "invalid value for count (NaN)" # legacy
|
||||
assert resp.json['err_class'] == "invalid value for count (NaN)"
|
||||
assert resp.json['err_desc'] == "invalid value for count (NaN)"
|
||||
assert resp.json['reason'] == 'invalid value for count (NaN)' # legacy
|
||||
assert resp.json['err_class'] == 'invalid value for count (NaN)'
|
||||
assert resp.json['err_desc'] == 'invalid value for count (NaN)'
|
||||
|
||||
resp = app.post('/api/agenda/%s/fillslot/%s/?count=0' % (agenda.slug, event.id), status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['reason'] == "count cannot be less than or equal to zero" # legacy
|
||||
assert resp.json['err_class'] == "count cannot be less than or equal to zero"
|
||||
assert resp.json['err_desc'] == "count cannot be less than or equal to zero"
|
||||
assert resp.json['reason'] == 'count cannot be less than or equal to zero' # legacy
|
||||
assert resp.json['err_class'] == 'count cannot be less than or equal to zero'
|
||||
assert resp.json['err_desc'] == 'count cannot be less than or equal to zero'
|
||||
|
||||
resp = app.post('/api/agenda/%s/fillslot/%s/?count=-3' % (agenda.slug, event.id), status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['reason'] == "count cannot be less than or equal to zero" # legacy
|
||||
assert resp.json['err_class'] == "count cannot be less than or equal to zero"
|
||||
assert resp.json['err_desc'] == "count cannot be less than or equal to zero"
|
||||
assert resp.json['reason'] == 'count cannot be less than or equal to zero' # legacy
|
||||
assert resp.json['err_class'] == 'count cannot be less than or equal to zero'
|
||||
assert resp.json['err_desc'] == 'count cannot be less than or equal to zero'
|
||||
|
||||
resp = app.post('/api/agenda/%s/fillslot/%s/?count=3' % (agenda.slug, event.id))
|
||||
Booking.objects.get(id=resp.json['booking_id'])
|
||||
|
@ -1503,17 +1503,17 @@ def test_multiple_booking_api_fillslots(app, user):
|
|||
app.authorization = ('Basic', ('john.doe', 'password'))
|
||||
resp = app.post('/api/agenda/%s/fillslots/?count=NaN' % agenda.slug, params={'slots': slots}, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['reason'] == "invalid value for count (NaN)" # legacy
|
||||
assert resp.json['err_class'] == "invalid value for count (NaN)"
|
||||
assert resp.json['err_desc'] == "invalid value for count (NaN)"
|
||||
assert resp.json['reason'] == 'invalid value for count (NaN)' # legacy
|
||||
assert resp.json['err_class'] == 'invalid value for count (NaN)'
|
||||
assert resp.json['err_desc'] == 'invalid value for count (NaN)'
|
||||
|
||||
resp = app.post(
|
||||
'/api/agenda/%s/fillslots/' % agenda.slug, params={'slots': slots, 'count': 'NaN'}, status=400
|
||||
)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['reason'] == "invalid payload" # legacy
|
||||
assert resp.json['err_class'] == "invalid payload"
|
||||
assert resp.json['err_desc'] == "invalid payload"
|
||||
assert resp.json['reason'] == 'invalid payload' # legacy
|
||||
assert resp.json['err_class'] == 'invalid payload'
|
||||
assert resp.json['err_desc'] == 'invalid payload'
|
||||
assert 'count' in resp.json['errors']
|
||||
|
||||
# get 3 places on 2 slots
|
||||
|
|
|
@ -1296,7 +1296,7 @@ def test_recurring_events_api_fillslots_multiple_agendas_queries(app, user):
|
|||
event.create_all_recurrences()
|
||||
with connection.cursor() as cursor:
|
||||
# force an analyze pass after we load data so PG has usable statistics
|
||||
cursor.execute("ANALYZE;")
|
||||
cursor.execute('ANALYZE;')
|
||||
|
||||
agenda_slugs = ','.join(str(i) for i in range(20))
|
||||
resp = app.get('/api/agendas/recurring-events/?action=update&agendas=%s' % agenda_slugs)
|
||||
|
|
|
@ -100,8 +100,8 @@ def test_booking_ics(app, some_data, meetings_agenda, user, settings, rf):
|
|||
end = (
|
||||
booking.event.start_datetime + datetime.timedelta(minutes=booking.event.meeting_type.duration)
|
||||
).strftime('%Y%m%dT%H%M%S')
|
||||
assert "DTSTART:%sZ\r\n" % start in booking_ics
|
||||
assert "DTEND:%sZ\r\n" % end in booking_ics
|
||||
assert 'DTSTART:%sZ\r\n' % start in booking_ics
|
||||
assert 'DTEND:%sZ\r\n' % end in booking_ics
|
||||
|
||||
|
||||
def test_bookings_api(app, user):
|
||||
|
@ -250,8 +250,8 @@ def test_bookings_api_filter_date_start(app, user):
|
|||
for value in ['foo', '2017-05-42']:
|
||||
resp = app.get('/api/bookings/', params={'user_external_id': '42', 'date_start': value}, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_class'] == "invalid payload"
|
||||
assert resp.json['err_desc'] == "invalid payload"
|
||||
assert resp.json['err_class'] == 'invalid payload'
|
||||
assert resp.json['err_desc'] == 'invalid payload'
|
||||
|
||||
resp = app.get('/api/bookings/', params={'user_external_id': '42', 'date_start': '2017-05-21'})
|
||||
assert resp.json['err'] == 0
|
||||
|
@ -287,8 +287,8 @@ def test_bookings_api_filter_date_end(app, user):
|
|||
for value in ['foo', '2017-05-42']:
|
||||
resp = app.get('/api/bookings/', params={'user_external_id': '42', 'date_end': value}, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_class'] == "invalid payload"
|
||||
assert resp.json['err_desc'] == "invalid payload"
|
||||
assert resp.json['err_class'] == 'invalid payload'
|
||||
assert resp.json['err_desc'] == 'invalid payload'
|
||||
|
||||
resp = app.get('/api/bookings/', params={'user_external_id': '42', 'date_end': '2017-05-21'})
|
||||
assert resp.json['err'] == 0
|
||||
|
|
|
@ -1041,12 +1041,12 @@ def test_import_event_nested_quotes(app, admin_user):
|
|||
't.csv',
|
||||
','.join(
|
||||
[
|
||||
"2016-09-16",
|
||||
"18:00",
|
||||
"10",
|
||||
"5",
|
||||
"éléphant",
|
||||
"elephant",
|
||||
'2016-09-16',
|
||||
'18:00',
|
||||
'10',
|
||||
'5',
|
||||
'éléphant',
|
||||
'elephant',
|
||||
# the multiline description and final dot
|
||||
# and new line after ""éléphants"" are needed to trigger the bug.
|
||||
'''"Animation:
|
||||
|
@ -1571,7 +1571,7 @@ def test_event_check(app, admin_user):
|
|||
resp = resp.click('Check')
|
||||
assert (
|
||||
resp.text.index('Bookings (6/10)')
|
||||
< resp.text.index("User's 01")
|
||||
< resp.text.index('User's 01')
|
||||
< resp.text.index('User 05')
|
||||
< resp.text.index('User 17')
|
||||
< resp.text.index('User 35')
|
||||
|
@ -1633,7 +1633,7 @@ def test_event_check(app, admin_user):
|
|||
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk))
|
||||
assert (
|
||||
resp.text.index('Bookings (6/10)')
|
||||
< resp.text.index("User's 01")
|
||||
< resp.text.index('User's 01')
|
||||
< resp.text.index('User 05')
|
||||
< resp.text.index('User 12 Cancelled')
|
||||
< resp.text.index('Subscription 14')
|
||||
|
@ -3300,7 +3300,7 @@ def test_duplicate_event(app, admin_user):
|
|||
label='Foo',
|
||||
duration=45,
|
||||
pricing='200€',
|
||||
url="http://example.com",
|
||||
url='http://example.com',
|
||||
description='foo',
|
||||
)
|
||||
|
||||
|
@ -3313,7 +3313,7 @@ def test_duplicate_event(app, admin_user):
|
|||
app = login(app)
|
||||
resp = app.get(f'/manage/agendas/{agenda.pk}/settings')
|
||||
resp = resp.click('Duplicate', href='events')
|
||||
resp.form['label'] = "Bar"
|
||||
resp.form['label'] = 'Bar'
|
||||
resp.form['start_datetime_0'] = str(new_datetime.date())
|
||||
resp.form['start_datetime_1'] = '17:00'
|
||||
|
||||
|
@ -3326,7 +3326,7 @@ def test_duplicate_event(app, admin_user):
|
|||
assert duplicate.start_datetime == new_datetime
|
||||
assert duplicate.agenda == event.agenda
|
||||
|
||||
updated_fields = {"label", "start_datetime"}
|
||||
updated_fields = {'label', 'start_datetime'}
|
||||
identical_fields = {f.name for f in Event._meta.fields} - updated_fields - {'id', 'slug'}
|
||||
for field in identical_fields:
|
||||
assert getattr(duplicate, field) == getattr(event, field)
|
||||
|
@ -3351,7 +3351,7 @@ def test_duplicate_event_creates_recurrences(app, admin_user):
|
|||
app = login(app)
|
||||
resp = app.get(f'/manage/agendas/{agenda.pk}/settings')
|
||||
resp = resp.click('Duplicate', href='events')
|
||||
resp.form['label'] = "Bar"
|
||||
resp.form['label'] = 'Bar'
|
||||
resp.form['start_datetime_0'] = str(event_start.date())
|
||||
resp.form['start_datetime_1'] = '17:00'
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ def test_meetings_agenda_add_time_period_exception(app, admin_user):
|
|||
assert TimePeriodException.objects.count() == 2
|
||||
assert 'Exception 1' in resp.text
|
||||
assert 'Exception 2' not in resp.text
|
||||
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-extract-list" % desk.pk)
|
||||
resp = resp.click(href='/manage/time-period-exceptions/%d/exception-extract-list' % desk.pk)
|
||||
assert 'Exception 1' in resp.text
|
||||
assert 'Exception 2' in resp.text
|
||||
|
||||
|
@ -526,23 +526,23 @@ def test_exception_list(app, admin_user):
|
|||
assert '/manage/time-period-exceptions/%d/edit' % current_exception.pk in resp.text
|
||||
assert '/manage/time-period-exceptions/%d/edit' % future_exception.pk in resp.text
|
||||
|
||||
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-extract-list" % desk.pk)
|
||||
resp = resp.click(href='/manage/time-period-exceptions/%d/exception-extract-list' % desk.pk)
|
||||
assert '/manage/time-period-exceptions/%d/edit' % past_exception.pk not in resp.text
|
||||
assert '/manage/time-period-exceptions/%d/edit' % current_exception.pk in resp.text
|
||||
assert '/manage/time-period-exceptions/%d/edit' % future_exception.pk in resp.text
|
||||
|
||||
resp = resp.click(href="/manage/time-period-exceptions/%d/exception-list" % desk.pk)
|
||||
resp = resp.click(href='/manage/time-period-exceptions/%d/exception-list' % desk.pk)
|
||||
assert '/manage/time-period-exceptions/%d/edit' % past_exception.pk not in resp.text
|
||||
assert '/manage/time-period-exceptions/%d/edit' % current_exception.pk in resp.text
|
||||
assert '/manage/time-period-exceptions/%d/edit' % future_exception.pk in resp.text
|
||||
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
app.get("/manage/time-period-exceptions/%d/exception-list" % desk.pk)
|
||||
app.get('/manage/time-period-exceptions/%d/exception-list' % desk.pk)
|
||||
assert len(ctx.captured_queries) == 6
|
||||
|
||||
desk.import_timeperiod_exceptions_from_settings(enable=True)
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
app.get("/manage/time-period-exceptions/%d/exception-list" % desk.pk)
|
||||
app.get('/manage/time-period-exceptions/%d/exception-list' % desk.pk)
|
||||
assert len(ctx.captured_queries) == 6
|
||||
|
||||
# add an unavailability calendar
|
||||
|
@ -568,8 +568,8 @@ def test_exception_list(app, admin_user):
|
|||
unavailability_calendar.desks.add(desk)
|
||||
|
||||
for url in (
|
||||
"/manage/time-period-exceptions/%d/exception-extract-list" % desk.pk,
|
||||
"/manage/time-period-exceptions/%d/exception-list" % desk.pk,
|
||||
'/manage/time-period-exceptions/%d/exception-extract-list' % desk.pk,
|
||||
'/manage/time-period-exceptions/%d/exception-list' % desk.pk,
|
||||
):
|
||||
resp = app.get(url)
|
||||
assert 'Calendar Past Exception' not in resp.text
|
||||
|
@ -588,7 +588,7 @@ def test_agenda_import_time_period_exception_from_ics(app, admin_user):
|
|||
resp = app.get('/manage/agendas/%d/settings' % agenda.pk)
|
||||
assert 'Manage exception sources' in resp.text
|
||||
resp = resp.click('manage exceptions', index=0)
|
||||
assert "To add new exceptions, you can upload a file or specify an address to a remote calendar." in resp
|
||||
assert 'To add new exceptions, you can upload a file or specify an address to a remote calendar.' in resp
|
||||
resp = resp.form.submit(status=200)
|
||||
assert 'Please provide an ICS File or an URL.' in resp.text
|
||||
assert TimePeriodExceptionSource.objects.filter(desk=desk).count() == 0
|
||||
|
@ -614,7 +614,7 @@ PRODID:-//foo.bar//EN
|
|||
END:VCALENDAR"""
|
||||
resp.form['ics_file'] = Upload('exceptions.ics', ics_with_no_events, 'text/calendar')
|
||||
resp = resp.form.submit(status=200)
|
||||
assert "The file doesn't contain any events." in resp.text
|
||||
assert 'The file doesn't contain any events.' in resp.text
|
||||
assert TimePeriodExceptionSource.objects.filter(desk=desk).count() == 0
|
||||
|
||||
ics_with_exceptions = b"""BEGIN:VCALENDAR
|
||||
|
@ -1442,7 +1442,7 @@ def test_unavailability_calendar_import_time_period_exception_from_ics(app, admi
|
|||
resp = app.get('/manage/unavailability-calendar/%d/settings' % calendar.pk)
|
||||
assert 'Manage unavailabilities from ICS' in resp.text
|
||||
resp = resp.click('Manage unavailabilities')
|
||||
assert "To add new exceptions, you can upload a file or specify an address to a remote calendar." in resp
|
||||
assert 'To add new exceptions, you can upload a file or specify an address to a remote calendar.' in resp
|
||||
resp = resp.form.submit(status=200)
|
||||
assert 'Please provide an ICS File or an URL.' in resp.text
|
||||
assert TimePeriodExceptionSource.objects.filter(unavailability_calendar=calendar).count() == 0
|
||||
|
|
|
@ -12,7 +12,7 @@ DATABASES = {
|
|||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'TEST': {
|
||||
'NAME': 'chrono-test-%s' % os.environ.get("BRANCH_NAME", "").replace('/', '-')[:45],
|
||||
'NAME': 'chrono-test-%s' % os.environ.get('BRANCH_NAME', '').replace('/', '-')[:45],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -47,4 +47,4 @@ SITE_BASE_URL = 'https://example.com'
|
|||
SHARED_CUSTODY_ENABLED = True
|
||||
LEGACY_FILLSLOTS_ENABLED = True
|
||||
|
||||
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
|
||||
PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher']
|
||||
|
|
|
@ -715,7 +715,7 @@ def test_timeperiodexception_creation_from_ics_without_startdt():
|
|||
if line.startswith('DTSTART:'):
|
||||
continue
|
||||
lines.append(line)
|
||||
ics_sample = ContentFile("\n".join(lines), name='sample.ics')
|
||||
ics_sample = ContentFile('\n'.join(lines), name='sample.ics')
|
||||
source = desk.timeperiodexceptionsource_set.create(ics_filename='sample.ics', ics_file=ics_sample)
|
||||
with pytest.raises(ICSError) as e:
|
||||
source._check_ics_content()
|
||||
|
@ -731,7 +731,7 @@ def test_timeperiodexception_creation_from_ics_without_enddt():
|
|||
if line.startswith('DTEND:'):
|
||||
continue
|
||||
lines.append(line)
|
||||
ics_sample = ContentFile("\n".join(lines), name='sample.ics')
|
||||
ics_sample = ContentFile('\n'.join(lines), name='sample.ics')
|
||||
source = desk.timeperiodexceptionsource_set.create(ics_filename='sample.ics', ics_file=ics_sample)
|
||||
source.refresh_timeperiod_exceptions_from_ics()
|
||||
for exception in TimePeriodException.objects.filter(desk=desk):
|
||||
|
@ -759,7 +759,7 @@ def test_timeexception_creation_from_ics_with_dates():
|
|||
if line.startswith('RRULE:'):
|
||||
continue
|
||||
lines.append(line)
|
||||
ics_sample = ContentFile("\n".join(lines), name='sample.ics')
|
||||
ics_sample = ContentFile('\n'.join(lines), name='sample.ics')
|
||||
source = desk.timeperiodexceptionsource_set.create(ics_filename='sample.ics', ics_file=ics_sample)
|
||||
source.refresh_timeperiod_exceptions_from_ics()
|
||||
assert TimePeriodException.objects.filter(desk=desk).count() == 2
|
||||
|
@ -838,7 +838,7 @@ def test_timeperiodexception_creation_from_unreachable_remote_ics(mocked_get):
|
|||
mocked_get.side_effect = mocked_requests_connection_error
|
||||
with pytest.raises(ICSError) as e:
|
||||
source._check_ics_content()
|
||||
assert str(e.value) == "Failed to retrieve remote calendar (http://example.com/sample.ics, unreachable)."
|
||||
assert str(e.value) == 'Failed to retrieve remote calendar (http://example.com/sample.ics, unreachable).'
|
||||
|
||||
|
||||
@mock.patch('chrono.agendas.models.requests.get')
|
||||
|
@ -857,7 +857,7 @@ def test_timeperiodexception_creation_from_forbidden_remote_ics(mocked_get):
|
|||
with pytest.raises(ICSError) as e:
|
||||
source._check_ics_content()
|
||||
assert (
|
||||
str(e.value) == "Failed to retrieve remote calendar (http://example.com/sample.ics, HTTP error 403)."
|
||||
str(e.value) == 'Failed to retrieve remote calendar (http://example.com/sample.ics, HTTP error 403).'
|
||||
)
|
||||
|
||||
|
||||
|
@ -1474,7 +1474,7 @@ def test_desk_duplicate():
|
|||
unavailability_calendar = UnavailabilityCalendar.objects.create(label='Calendar')
|
||||
unavailability_calendar.desks.add(desk)
|
||||
|
||||
new_desk = desk.duplicate(label="New Desk")
|
||||
new_desk = desk.duplicate(label='New Desk')
|
||||
assert new_desk.pk != desk.pk
|
||||
assert new_desk.label == 'New Desk'
|
||||
assert new_desk.slug == 'new-desk'
|
||||
|
@ -1498,7 +1498,7 @@ def test_desk_duplicate():
|
|||
assert new_desk.unavailability_calendars.get() == unavailability_calendar
|
||||
|
||||
# duplicate again !
|
||||
new_desk = desk.duplicate(label="New Desk")
|
||||
new_desk = desk.duplicate(label='New Desk')
|
||||
assert new_desk.slug == 'new-desk-1'
|
||||
|
||||
|
||||
|
@ -1511,7 +1511,7 @@ def test_desk_duplicate_exception_sources():
|
|||
source.refresh_timeperiod_exceptions_from_ics()
|
||||
assert TimePeriodException.objects.filter(desk=desk).count() == 2
|
||||
|
||||
new_desk = desk.duplicate(label="New Desk")
|
||||
new_desk = desk.duplicate(label='New Desk')
|
||||
new_source = new_desk.timeperiodexceptionsource_set.get(ics_filename='sample.ics')
|
||||
assert new_desk.timeperiodexception_set.count() == 2
|
||||
|
||||
|
@ -1541,14 +1541,14 @@ def test_desk_duplicate_exception_source_from_settings():
|
|||
assert source.enabled
|
||||
exceptions_count = desk.timeperiodexception_set.count()
|
||||
|
||||
new_desk = desk.duplicate(label="New Desk")
|
||||
new_desk = desk.duplicate(label='New Desk')
|
||||
assert new_desk.timeperiodexceptionsource_set.filter(settings_slug='holidays').count() == 1
|
||||
assert new_desk.timeperiodexceptionsource_set.get(settings_slug='holidays').enabled
|
||||
assert new_desk.timeperiodexception_set.count() == exceptions_count
|
||||
|
||||
source.disable()
|
||||
|
||||
new_desk = desk.duplicate(label="New Desk")
|
||||
new_desk = desk.duplicate(label='New Desk')
|
||||
assert not new_desk.timeperiodexceptionsource_set.get(settings_slug='holidays').enabled
|
||||
assert not new_desk.timeperiodexception_set.exists()
|
||||
|
||||
|
@ -2788,7 +2788,7 @@ def test_event_triggered_fields(partial_bookings):
|
|||
cursor.execute("SELECT nextval('agendas_event_id_seq')")
|
||||
row = cursor.fetchone()
|
||||
if row[0] < 2**31:
|
||||
cursor.execute("ALTER SEQUENCE agendas_event_id_seq RESTART WITH %s;" % 2**31)
|
||||
cursor.execute('ALTER SEQUENCE agendas_event_id_seq RESTART WITH %s;' % 2**31)
|
||||
|
||||
agenda = Agenda.objects.create(label='Agenda', kind='events', partial_bookings=partial_bookings)
|
||||
event = Event.objects.create(
|
||||
|
|
|
@ -13,19 +13,19 @@ pytestmark = pytest.mark.django_db
|
|||
|
||||
def check_ignore_reason(event, value):
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute("SELECT _ignore_reason FROM agendas_event WHERE id = %s", [event.pk])
|
||||
cursor.execute('SELECT _ignore_reason FROM agendas_event WHERE id = %s', [event.pk])
|
||||
row = cursor.fetchone()
|
||||
assert row[0] == value
|
||||
|
||||
|
||||
def set_ignore_reason(event, value):
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute("UPDATE agendas_event SET _ignore_reason = %s WHERE id = %s", [value, event.pk])
|
||||
cursor.execute('UPDATE agendas_event SET _ignore_reason = %s WHERE id = %s', [value, event.pk])
|
||||
|
||||
|
||||
def check_end_datetime(event, value):
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute("SELECT _end_datetime FROM agendas_event WHERE id = %s", [event.pk])
|
||||
cursor.execute('SELECT _end_datetime FROM agendas_event WHERE id = %s', [event.pk])
|
||||
row = cursor.fetchone()
|
||||
assert row[0] == value
|
||||
|
||||
|
|
|
@ -32,4 +32,4 @@ def mocked_requests_send(request, **kwargs):
|
|||
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
||||
def test_publik_django_templatetags_integration(mock_send, context, nocache):
|
||||
t = Template('{{ cards|objects:"foo"|count }}')
|
||||
assert t.render(context) == "2"
|
||||
assert t.render(context) == '2'
|
||||
|
|
Loading…
Reference in New Issue