Skip to content

Commit

Permalink
#476 Fix W391 blank line at end of file
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlittle committed Nov 3, 2019
1 parent 91bd466 commit efc9c97
Show file tree
Hide file tree
Showing 29 changed files with 131 additions and 121 deletions.
17 changes: 10 additions & 7 deletions gamification/forms.py
Expand Up @@ -36,7 +36,9 @@ def __init__(self, *args, **kwargs):

self.helper.layout.append(
Div(
Submit('submit', _(u'Update points'), css_class='btn btn-default'),
Submit('submit',
_(u'Update points'),
css_class='btn btn-default'),
css_class='col-lg-offset-2 col-lg-4',
))

Expand Down Expand Up @@ -75,7 +77,9 @@ def __init__(self, *args, **kwargs):

self.helper.layout.append(
Div(
Submit('submit', _(u'Update points'), css_class='btn btn-default'),
Submit('submit',
_(u'Update points'),
css_class='btn btn-default'),
css_class='col-lg-offset-2 col-lg-4',
))

Expand Down Expand Up @@ -114,7 +118,9 @@ def __init__(self, *args, **kwargs):

self.helper.layout.append(
Div(
Submit('submit', _(u'Update points'), css_class='btn btn-default'),
Submit('submit',
_(u'Update points'),
css_class='btn btn-default'),
css_class='col-lg-offset-2 col-lg-4',
))

Expand All @@ -127,7 +133,4 @@ class GamificationEventForm(forms.Form):
level = forms.CharField(widget=forms.HiddenInput())
event = forms.CharField(widget=forms.HiddenInput())
points = forms.IntegerField(widget=forms.HiddenInput())
reference = forms.IntegerField(widget=forms.HiddenInput())



reference = forms.IntegerField(widget=forms.HiddenInput())
7 changes: 3 additions & 4 deletions integrations/urls.py
Expand Up @@ -4,9 +4,8 @@
from integrations import views as oppia_integrations_views

urlpatterns = [
url(r'^$', oppia_integrations_views.home, name="oppia_integrations_home"),
url(r'^$', oppia_integrations_views.home,
name="oppia_integrations_home"),
url(r'^dhis/', include('integrations.dhis.urls')),
url(r'^xapi/', include('integrations.xapi.urls')),
]


]
5 changes: 1 addition & 4 deletions oppia/management/commands/oppiacron.py
Expand Up @@ -58,7 +58,4 @@ def handle(self, *args, **options):
call_command('generate_media_images')

SettingProperties.set_string('oppia_cron_last_run', timezone.now())
SettingProperties.delete_key('oppia_cron_lock')



SettingProperties.delete_key('oppia_cron_lock')
1 change: 0 additions & 1 deletion oppia/urls.py
Expand Up @@ -43,4 +43,3 @@
url(r'^view/$', oppia_views.app_launch_activity_redirect_view, name="oppia_app_launch_activity_redirect"),
url(r'^media/(?P<path>.*)$', static.serve, {'document_root': settings.MEDIA_ROOT}),
]

1 change: 0 additions & 1 deletion oppiamobile/settings.py
Expand Up @@ -226,4 +226,3 @@

if DEVICE_ADMIN_ENABLED:
INSTALLED_APPS += ('deviceadmin', 'gcm', )

3 changes: 1 addition & 2 deletions quiz/management/commands/check_duplicate_quizzes.py
Expand Up @@ -51,5 +51,4 @@ def handle(self, *args, **options):
" > Do you want to remove the {} quizzes without attempts?\n".format(len(quiz_to_delete)))

except Quiz.DoesNotExist:
pass

pass
3 changes: 1 addition & 2 deletions quiz/models/response.py
Expand Up @@ -39,5 +39,4 @@ def __unicode__(self):
return self.name

def __str__(self):
return self.name

return self.name
3 changes: 1 addition & 2 deletions settings/models.py
Expand Up @@ -65,5 +65,4 @@ def __unicode__(self):
return self.key

def __str__(self):
return self.key

return self.key
9 changes: 4 additions & 5 deletions tests/activitylog/test_activitylog.py
Expand Up @@ -38,7 +38,7 @@ def test_no_file(self):
def test_wrong_format_file(self):
self.client.login(username=ADMIN_USER['user'],
password=ADMIN_USER['password'])
# Commented out until we can figure out the problem with testserver making http requests

with open(self.wrong_activity_file, 'rb') as activity_log_file:
response = self.client.post(self.url,
{'activity_log_file': activity_log_file})
Expand All @@ -53,7 +53,7 @@ def test_correct_file(self):

self.client.login(username=ADMIN_USER['user'],
password=ADMIN_USER['password'])
# Commented out until we can figure out the problem with testserver making http requests

with open(self.basic_activity_log, 'rb') as activity_log_file:
response = self.client.post(self.url,
{'activity_log_file': activity_log_file})
Expand All @@ -73,7 +73,7 @@ def test_new_user_file(self):

self.client.login(username=ADMIN_USER['user'],
password=ADMIN_USER['password'])
# Commented out until we can figure out the problem with testserver making http requests

with open(self.new_user_activity, 'rb') as activity_log_file:
response = self.client.post(self.url,
{'activity_log_file': activity_log_file})
Expand All @@ -87,5 +87,4 @@ def test_new_user_file(self):
tracker_count_end = Tracker.objects.all().count()
user_count_end = User.objects.all().count()
self.assertEqual(tracker_count_start + 2, tracker_count_end)
self.assertEqual(user_count_start + 1, user_count_end)

self.assertEqual(user_count_start + 1, user_count_end)
4 changes: 1 addition & 3 deletions tests/api/test_course_publish.py
Expand Up @@ -230,6 +230,4 @@ def test_course_filesize_limit(self):
new_no_cpls = CoursePublishingLog.objects.filter(action='over_max_upload').count()
self.assertEqual(old_no_cpls+1, new_no_cpls)

# TODO - check overwriting course with older version


# TODO - check overwriting course with older version
10 changes: 5 additions & 5 deletions tests/api/test_media_upload.py
Expand Up @@ -42,8 +42,10 @@ def test_required_params(self):
'media_file': video_file})
self.assertEqual(response.status_code, 400)

video_file.close() # shouldn't be strictly necessary to close the file, but avoids ResourceWarnings about unclosed files

# shouldn't be strictly necessary to close the file,
# but avoids ResourceWarnings about unclosed files
video_file.close()

# check authentication check working correctly
def test_authentication(self):

Expand Down Expand Up @@ -129,6 +131,4 @@ def test_filetype(self):

course_file.close()
# shouldn't be strictly necessary to close the file,
# but avoids ResourceWarnings about unclosed files


# but avoids ResourceWarnings about unclosed files
3 changes: 1 addition & 2 deletions tests/api/test_register.py
Expand Up @@ -223,5 +223,4 @@ def test_self_registration_disabled_cant_view(self):
self.assertValidJSON(response.content)

# turn back on
SettingProperties.set_int(constants.OPPIA_ALLOW_SELF_REGISTRATION, 1)

SettingProperties.set_int(constants.OPPIA_ALLOW_SELF_REGISTRATION, 1)
24 changes: 14 additions & 10 deletions tests/av/test_media_upload.py
Expand Up @@ -28,13 +28,17 @@ def setUp(self):
def test_upload_template(self):

media_file_content = open(self.media_file_path, 'rb')
media_file = SimpleUploadedFile(media_file_content.name, media_file_content.read(), content_type="video/m4v")

self.client.login(username=ADMIN_USER['user'], password=ADMIN_USER['password'])
response = self.client.post(reverse('oppia_av_upload'), {'media_file': media_file})
self.assertRedirects(response, reverse('oppia_av_upload_success', args=[1]), 302, 200)

media_file_content.close()



media_file = SimpleUploadedFile(media_file_content.name,
media_file_content.read(),
content_type="video/m4v")

self.client.login(username=ADMIN_USER['user'],
password=ADMIN_USER['password'])
response = self.client.post(reverse('oppia_av_upload'),
{'media_file': media_file})
self.assertRedirects(response, reverse('oppia_av_upload_success',
args=[1]),
302,
200)

media_file_content.close()
5 changes: 1 addition & 4 deletions tests/gamification/test_permissions.py
Expand Up @@ -73,7 +73,4 @@ def testUnknownCoursePointsEdit(self):
password=NORMAL_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',
args=[55]))
self.assertEqual(response.status_code, 403)



self.assertEqual(response.status_code, 403)
23 changes: 14 additions & 9 deletions tests/integrations/dhis/test_dhis_permissions.py
Expand Up @@ -28,7 +28,8 @@ def get_view(self, route, user=None):
def test_anon_cantview_integrations_home(self):
route = reverse('oppia_integrations_dhis_home')
res = self.get_view(route, None)
self.assertRedirects(res, self.login_url + '?next=/integrations/dhis/')
self.assertRedirects(res,
self.login_url + '?next=/integrations/dhis/')

def test_admin_canview_integrations_home(self):
route = reverse('oppia_integrations_dhis_home')
Expand All @@ -55,7 +56,8 @@ def test_user_with_canupload_integrations_home(self):
def test_anon_cantview_integrations_latest(self):
route = reverse('oppia_integrations_dhis_export_latest')
res = self.get_view(route, None)
self.assertRedirects(res, self.login_url + '?next=/integrations/dhis/export/latest/')
self.assertRedirects(res,
self.login_url + '?next=/integrations/dhis/export/latest/')

def test_admin_canview_integrations_latest(self):
route = reverse('oppia_integrations_dhis_export_latest')
Expand All @@ -70,20 +72,23 @@ def test_staff_canview_integrations_latest(self):
def test_student_cantview_integrations_latest(self):
route = reverse('oppia_integrations_dhis_export_latest')
res = self.get_view(route, NORMAL_USER)
self.assertRedirects(res, '/admin/login/?next=/integrations/dhis/export/latest/')
self.assertRedirects(res,
'/admin/login/?next=/integrations/dhis/export/latest/')

def test_user_with_canupload_integrations_latest(self):
route = reverse('oppia_integrations_dhis_export_latest')
res = self.get_view(route, TEACHER_USER)
self.assertRedirects(res, '/admin/login/?next=/integrations/dhis/export/latest/')
self.assertRedirects(res,
'/admin/login/?next=/integrations/dhis/export/latest/')

# test permissions and response for other months

def test_anon_cantview_integrations_monthly(self):
route = reverse('oppia_integrations_dhis_export_month',
kwargs={'year': 2019, 'month': 10})
res = self.get_view(route, None)
self.assertRedirects(res, self.login_url + '?next=/integrations/dhis/export/2019/10')
self.assertRedirects(res,
self.login_url + '?next=/integrations/dhis/export/2019/10')

def test_admin_canview_integrations_monthly(self):
route = reverse('oppia_integrations_dhis_export_month',
Expand All @@ -101,12 +106,12 @@ def test_student_cantview_integrations_monthly(self):
route = reverse('oppia_integrations_dhis_export_month',
kwargs={'year': 2019, 'month': 10})
res = self.get_view(route, NORMAL_USER)
self.assertRedirects(res, '/admin/login/?next=/integrations/dhis/export/2019/10')
self.assertRedirects(res,
'/admin/login/?next=/integrations/dhis/export/2019/10')

def test_user_with_canupload_integrations_monthly(self):
route = reverse('oppia_integrations_dhis_export_month',
kwargs={'year': 2019, 'month': 10})
res = self.get_view(route, TEACHER_USER)
self.assertRedirects(res, '/admin/login/?next=/integrations/dhis/export/2019/10')


self.assertRedirects(res,
'/admin/login/?next=/integrations/dhis/export/2019/10')
7 changes: 3 additions & 4 deletions tests/integrations/test_integrations.py
Expand Up @@ -19,7 +19,8 @@ def setUp(self):

def get_view(self, route, user=None):
if user is not None:
self.client.login(username=user['user'], password=user['password'])
self.client.login(username=user['user'],
password=user['password'])
return self.client.get(route)

def test_anon_cantview_integrations_home(self):
Expand All @@ -45,6 +46,4 @@ def test_student_cantview_integrations_home(self):
def test_user_with_canupload_integrations_home(self):
route = reverse('oppia_integrations_home')
res = self.get_view(route, TEACHER_USER)
self.assertRedirects(res, '/admin/login/?next=/integrations/')


self.assertRedirects(res, '/admin/login/?next=/integrations/')
17 changes: 10 additions & 7 deletions tests/integrations/xapi/test_xapi_permissions.py
Expand Up @@ -19,15 +19,17 @@ def setUp(self):

def get_view(self, route, user=None):
if user is not None:
self.client.login(username=user['user'], password=user['password'])
self.client.login(username=user['user'],
password=user['password'])
return self.client.get(route)

# test permissions for home

def test_anon_cantview_integrations_home(self):
route = reverse('oppia_integrations_xapi_home')
res = self.get_view(route, None)
self.assertRedirects(res, self.login_url + '?next=/integrations/xapi/')
self.assertRedirects(res,
self.login_url + '?next=/integrations/xapi/')

def test_admin_canview_integrations_home(self):
route = reverse('oppia_integrations_xapi_home')
Expand All @@ -54,7 +56,8 @@ def test_user_with_canupload_integrations_home(self):
def test_anon_cantview_integrations_latest(self):
route = reverse('oppia_integrations_xapi_csv_export')
res = self.get_view(route, None)
self.assertRedirects(res, self.login_url + '?next=/integrations/xapi/export/')
self.assertRedirects(res,
self.login_url + '?next=/integrations/xapi/export/')

def test_admin_canview_integrations_latest(self):
route = reverse('oppia_integrations_xapi_csv_export')
Expand All @@ -69,11 +72,11 @@ def test_staff_canview_integrations_latest(self):
def test_student_cantview_integrations_latest(self):
route = reverse('oppia_integrations_xapi_csv_export')
res = self.get_view(route, NORMAL_USER)
self.assertRedirects(res, '/admin/login/?next=/integrations/xapi/export/')
self.assertRedirects(res,
'/admin/login/?next=/integrations/xapi/export/')

def test_user_with_canupload_integrations_latest(self):
route = reverse('oppia_integrations_xapi_csv_export')
res = self.get_view(route, TEACHER_USER)
self.assertRedirects(res, '/admin/login/?next=/integrations/xapi/export/')


self.assertRedirects(res,
'/admin/login/?next=/integrations/xapi/export/')
10 changes: 5 additions & 5 deletions tests/oppia/uploader/test_helpers.py
Expand Up @@ -29,12 +29,14 @@ def test_create_quiz_props(self):

create_quiz_props(quiz, quiz_obj)

# now check the props have been saved correctly (using the sample quiz file)
# now check the props have been saved correctly
# (using the sample quiz file)
quiz_prop_count = QuizProps.objects.filter(quiz=quiz).count()
self.assertEqual(quiz_prop_count, 7)

digest = QuizProps.objects.get(quiz=quiz, name='digest')
self.assertEqual(digest.value, "4d46a0566501cdbc1f57b2b505c92a2d17703cr0s2a1p80a0")
self.assertEqual(digest.value,
"4d46a0566501cdbc1f57b2b505c92a2d17703cr0s2a1p80a0")

def test_create_quiz_questions(self):
quiz = Quiz.objects.get(pk=1)
Expand All @@ -54,6 +56,4 @@ def test_create_quiz_questions(self):

# check no questions
no_questions = QuizQuestion.objects.filter(quiz=quiz).count()
self.assertEqual(no_questions, 10)


self.assertEqual(no_questions, 10)
3 changes: 1 addition & 2 deletions tests/profile/views/test_user_activity.py
Expand Up @@ -117,5 +117,4 @@ def test_user_view_others_activity(self):
password=NORMAL_USER['password'])
response = self.client.get(url)
self.assertTemplateUsed(response, self.unauthorised_template)
self.assertEqual(response.status_code, 403)

self.assertEqual(response.status_code, 403)

0 comments on commit efc9c97

Please sign in to comment.