Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
7ba83dd5
Unverified
Commit
7ba83dd5
authored
Dec 14, 2017
by
Jeremy Bowman
Committed by
GitHub
Dec 14, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16908 from edx/jmbowman/PLAT-1847
PLAT-1847 Fix cms tests under Django 1.9
parents
088aec98
d44e6297
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
12 deletions
+36
-12
cms/djangoapps/contentstore/views/tests/test_videos.py
+1
-1
cms/djangoapps/contentstore/views/videos.py
+2
-0
common/djangoapps/microsite_configuration/tests/factories.py
+1
-0
common/djangoapps/student/tests/test_events.py
+1
-1
common/djangoapps/util/tests/test_db.py
+2
-0
openedx/core/djangoapps/external_auth/tests/test_ssl.py
+7
-6
openedx/core/djangoapps/schedules/tests/test_signals.py
+2
-4
openedx/tests/util/__init__.py
+20
-0
No files found.
cms/djangoapps/contentstore/views/tests/test_videos.py
View file @
7ba83dd5
...
@@ -659,7 +659,7 @@ class VideoImageTestCase(VideoUploadTestBase, CourseTestCase):
...
@@ -659,7 +659,7 @@ class VideoImageTestCase(VideoUploadTestBase, CourseTestCase):
error
=
validate_video_image
({})
error
=
validate_video_image
({})
self
.
assertEquals
(
error
,
'The image must have name, content type, and size information.'
)
self
.
assertEquals
(
error
,
'The image must have name, content type, and size information.'
)
def
test_c
u
rrupt_image_file
(
self
):
def
test_c
o
rrupt_image_file
(
self
):
"""
"""
Test that when corrupt file is provided to validate_video_image, it gives proper error message.
Test that when corrupt file is provided to validate_video_image, it gives proper error message.
"""
"""
...
...
cms/djangoapps/contentstore/views/videos.py
View file @
7ba83dd5
...
@@ -213,6 +213,8 @@ def validate_video_image(image_file):
...
@@ -213,6 +213,8 @@ def validate_video_image(image_file):
image_file_width
,
image_file_height
=
get_image_dimensions
(
image_file
)
image_file_width
,
image_file_height
=
get_image_dimensions
(
image_file
)
except
TypeError
:
except
TypeError
:
return
_
(
'There is a problem with this image file. Try to upload a different file.'
)
return
_
(
'There is a problem with this image file. Try to upload a different file.'
)
if
image_file_width
is
None
or
image_file_height
is
None
:
return
_
(
'There is a problem with this image file. Try to upload a different file.'
)
image_file_aspect_ratio
=
abs
(
image_file_width
/
float
(
image_file_height
)
-
settings
.
VIDEO_IMAGE_ASPECT_RATIO
)
image_file_aspect_ratio
=
abs
(
image_file_width
/
float
(
image_file_height
)
-
settings
.
VIDEO_IMAGE_ASPECT_RATIO
)
if
image_file_width
<
settings
.
VIDEO_IMAGE_MIN_WIDTH
or
image_file_height
<
settings
.
VIDEO_IMAGE_MIN_HEIGHT
:
if
image_file_width
<
settings
.
VIDEO_IMAGE_MIN_WIDTH
or
image_file_height
<
settings
.
VIDEO_IMAGE_MIN_HEIGHT
:
error
=
_
(
'Recommended image resolution is {image_file_max_width}x{image_file_max_height}. '
error
=
_
(
'Recommended image resolution is {image_file_max_width}x{image_file_max_height}. '
...
...
common/djangoapps/microsite_configuration/tests/factories.py
View file @
7ba83dd5
...
@@ -14,6 +14,7 @@ class SiteFactory(DjangoModelFactory):
...
@@ -14,6 +14,7 @@ class SiteFactory(DjangoModelFactory):
"""
"""
class
Meta
(
object
):
class
Meta
(
object
):
model
=
Site
model
=
Site
django_get_or_create
=
(
'domain'
,)
name
=
"test microsite"
name
=
"test microsite"
domain
=
"test-site.testserver"
domain
=
"test-site.testserver"
...
...
common/djangoapps/student/tests/test_events.py
View file @
7ba83dd5
...
@@ -130,7 +130,7 @@ class TestUserEvents(UserSettingsEventTestMixin, TestCase):
...
@@ -130,7 +130,7 @@ class TestUserEvents(UserSettingsEventTestMixin, TestCase):
"""
"""
Verify that we don't emit events for related fields.
Verify that we don't emit events for related fields.
"""
"""
self
.
user
.
passwordhistory_set
.
add
(
PasswordHistory
(
password
=
'new_password'
)
)
self
.
user
.
passwordhistory_set
.
create
(
password
=
'new_password'
)
self
.
user
.
save
()
self
.
user
.
save
()
self
.
assert_no_events_were_emitted
()
self
.
assert_no_events_were_emitted
()
...
...
common/djangoapps/util/tests/test_db.py
View file @
7ba83dd5
...
@@ -5,6 +5,7 @@ import time
...
@@ -5,6 +5,7 @@ import time
import
unittest
import
unittest
import
ddt
import
ddt
import
pytest
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.core.management
import
call_command
from
django.core.management
import
call_command
from
django.db
import
IntegrityError
,
connection
from
django.db
import
IntegrityError
,
connection
...
@@ -215,6 +216,7 @@ class GenerateIntIdTestCase(TestCase):
...
@@ -215,6 +216,7 @@ class GenerateIntIdTestCase(TestCase):
self
.
assertIn
(
int_id
,
list
(
set
(
range
(
minimum
,
maximum
+
1
))
-
used_ids
))
self
.
assertIn
(
int_id
,
list
(
set
(
range
(
minimum
,
maximum
+
1
))
-
used_ids
))
@pytest.mark.django111_expected_failure
class
MigrationTests
(
TestCase
):
class
MigrationTests
(
TestCase
):
"""
"""
Tests for migrations.
Tests for migrations.
...
...
openedx/core/djangoapps/external_auth/tests/test_ssl.py
View file @
7ba83dd5
...
@@ -20,6 +20,7 @@ from openedx.core.djangoapps.external_auth.models import ExternalAuthMap
...
@@ -20,6 +20,7 @@ from openedx.core.djangoapps.external_auth.models import ExternalAuthMap
import
openedx.core.djangoapps.external_auth.views
as
external_auth_views
import
openedx.core.djangoapps.external_auth.views
as
external_auth_views
from
openedx.core.djangoapps.site_configuration.tests.factories
import
SiteFactory
from
openedx.core.djangoapps.site_configuration.tests.factories
import
SiteFactory
from
openedx.core.djangolib.testing.utils
import
skip_unless_cms
,
skip_unless_lms
from
openedx.core.djangolib.testing.utils
import
skip_unless_cms
,
skip_unless_lms
from
openedx.tests.util
import
expected_redirect_url
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
from
student.roles
import
CourseStaffRole
from
student.roles
import
CourseStaffRole
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
UserFactory
...
@@ -182,7 +183,7 @@ class SSLClientTest(ModuleStoreTestCase):
...
@@ -182,7 +183,7 @@ class SSLClientTest(ModuleStoreTestCase):
response
=
self
.
client
.
get
(
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
),
follow
=
True
,
reverse
(
'dashboard'
),
follow
=
True
,
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
))
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
))
self
.
assertEquals
((
'http://testserver/dashboard'
,
302
),
self
.
assertEquals
((
expected_redirect_url
(
'/dashboard'
)
,
302
),
response
.
redirect_chain
[
-
1
])
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
...
@@ -196,7 +197,7 @@ class SSLClientTest(ModuleStoreTestCase):
...
@@ -196,7 +197,7 @@ class SSLClientTest(ModuleStoreTestCase):
response
=
self
.
client
.
get
(
response
=
self
.
client
.
get
(
reverse
(
'register_user'
),
follow
=
True
,
reverse
(
'register_user'
),
follow
=
True
,
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
))
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
))
self
.
assertEquals
((
'http://testserver/dashboard'
,
302
),
self
.
assertEquals
((
expected_redirect_url
(
'/dashboard'
)
,
302
),
response
.
redirect_chain
[
-
1
])
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
...
@@ -236,7 +237,7 @@ class SSLClientTest(ModuleStoreTestCase):
...
@@ -236,7 +237,7 @@ class SSLClientTest(ModuleStoreTestCase):
response
=
self
.
client
.
get
(
response
=
self
.
client
.
get
(
reverse
(
'signin_user'
),
follow
=
True
,
reverse
(
'signin_user'
),
follow
=
True
,
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
))
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
))
self
.
assertEquals
((
'http://testserver/dashboard'
,
302
),
self
.
assertEquals
((
expected_redirect_url
(
'/dashboard'
)
,
302
),
response
.
redirect_chain
[
-
1
])
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
...
@@ -359,7 +360,7 @@ class SSLClientTest(ModuleStoreTestCase):
...
@@ -359,7 +360,7 @@ class SSLClientTest(ModuleStoreTestCase):
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
),
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
),
HTTP_ACCEPT
=
'text/html'
HTTP_ACCEPT
=
'text/html'
)
)
self
.
assertEqual
((
'http://testserver{0}'
.
format
(
course_private_url
),
302
),
self
.
assertEqual
((
expected_redirect_url
(
course_private_url
),
302
),
response
.
redirect_chain
[
-
1
])
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
...
@@ -391,7 +392,7 @@ class SSLClientTest(ModuleStoreTestCase):
...
@@ -391,7 +392,7 @@ class SSLClientTest(ModuleStoreTestCase):
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
),
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
),
HTTP_ACCEPT
=
'text/html'
HTTP_ACCEPT
=
'text/html'
)
)
self
.
assertEqual
((
'http://testserver{0}'
.
format
(
course_private_url
),
302
),
self
.
assertEqual
((
expected_redirect_url
(
course_private_url
),
302
),
response
.
redirect_chain
[
-
1
])
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
...
@@ -409,7 +410,7 @@ class SSLClientTest(ModuleStoreTestCase):
...
@@ -409,7 +410,7 @@ class SSLClientTest(ModuleStoreTestCase):
response
=
self
.
client
.
get
(
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
),
follow
=
True
,
reverse
(
'dashboard'
),
follow
=
True
,
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
))
SSL_CLIENT_S_DN
=
self
.
AUTH_DN
.
format
(
self
.
USER_NAME
,
self
.
USER_EMAIL
))
self
.
assertEquals
((
'http://testserver/dashboard'
,
302
),
self
.
assertEquals
((
expected_redirect_url
(
'/dashboard'
)
,
302
),
response
.
redirect_chain
[
-
1
])
response
.
redirect_chain
[
-
1
])
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
self
.
assertIn
(
SESSION_KEY
,
self
.
client
.
session
)
response
=
self
.
client
.
get
(
response
=
self
.
client
.
get
(
...
...
openedx/core/djangoapps/schedules/tests/test_signals.py
View file @
7ba83dd5
...
@@ -151,10 +151,8 @@ class UpdateScheduleTests(SharedModuleStoreTestCase):
...
@@ -151,10 +151,8 @@ class UpdateScheduleTests(SharedModuleStoreTestCase):
def
assert_schedule_dates
(
self
,
schedule
,
expected_start
):
def
assert_schedule_dates
(
self
,
schedule
,
expected_start
):
assert
_strip_secs
(
schedule
.
start
)
==
_strip_secs
(
expected_start
)
assert
_strip_secs
(
schedule
.
start
)
==
_strip_secs
(
expected_start
)
assert
(
deadline_delta
=
datetime
.
timedelta
(
days
=
self
.
VERIFICATION_DEADLINE_DAYS
)
_strip_secs
(
schedule
.
upgrade_deadline
)
==
assert
_strip_secs
(
schedule
.
upgrade_deadline
)
==
_strip_secs
(
expected_start
)
+
deadline_delta
_strip_secs
(
expected_start
)
+
datetime
.
timedelta
(
days
=
self
.
VERIFICATION_DEADLINE_DAYS
),
)
def
test_updated_when_course_not_started
(
self
,
mock_get_current_site
):
def
test_updated_when_course_not_started
(
self
,
mock_get_current_site
):
mock_get_current_site
.
return_value
=
self
.
site
mock_get_current_site
.
return_value
=
self
.
site
...
...
openedx/tests/util/__init__.py
View file @
7ba83dd5
"""
Utilities for Open edX unit tests.
"""
from
__future__
import
absolute_import
,
unicode_literals
import
django
# TODO: Remove Django 1.11 upgrade shim
# SHIM: We should be able to get rid of this utility post-upgrade
def
expected_redirect_url
(
relative_url
,
hostname
=
'testserver'
):
"""
Get the expected redirect URL for the current Django version and the
given relative URL. Django 1.8 and earlier redirect to absolute URLs,
later versions redirect to relative ones.
"""
if
django
.
VERSION
<
(
1
,
9
):
return
'http://{}{}'
.
format
(
hostname
,
relative_url
)
else
:
return
relative_url
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment