Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
d2f7c81f
Commit
d2f7c81f
authored
Jun 26, 2018
by
Sanford Student
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
another revert
parent
6659595d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
course_discovery/apps/publisher/tests/test_signals.py
+10
-2
No files found.
course_discovery/apps/publisher/tests/test_signals.py
View file @
d2f7c81f
import
datetime
import
json
import
json
import
mock
import
mock
...
@@ -13,12 +14,11 @@ from course_discovery.apps.course_metadata.tests.factories import CourseRunFacto
...
@@ -13,12 +14,11 @@ from course_discovery.apps.course_metadata.tests.factories import CourseRunFacto
from
course_discovery.apps.course_metadata.tests.factories
import
OrganizationFactory
from
course_discovery.apps.course_metadata.tests.factories
import
OrganizationFactory
from
course_discovery.apps.publisher.studio_api_utils
import
StudioAPI
from
course_discovery.apps.publisher.studio_api_utils
import
StudioAPI
from
course_discovery.apps.publisher.tests.factories
import
CourseRunFactory
,
OrganizationExtensionFactory
from
course_discovery.apps.publisher.tests.factories
import
CourseRunFactory
,
OrganizationExtensionFactory
from
course_discovery.apps.publisher.tests.utils
import
MockedStartEndDateTestCase
@freeze_time
(
'2017-01-01T00:00:00Z'
)
@freeze_time
(
'2017-01-01T00:00:00Z'
)
@pytest.mark.django_db
@pytest.mark.django_db
class
TestCreateCourseRunInStudio
(
MockedStartEndDateTestCase
)
:
class
TestCreateCourseRunInStudio
:
@override_switch
(
'enable_publisher_create_course_run_in_studio'
,
active
=
True
)
@override_switch
(
'enable_publisher_create_course_run_in_studio'
,
active
=
True
)
def
test_create_course_run_in_studio_without_partner
(
self
):
def
test_create_course_run_in_studio_without_partner
(
self
):
with
mock
.
patch
(
'course_discovery.apps.publisher.signals.logger.error'
)
as
mock_logger
:
with
mock
.
patch
(
'course_discovery.apps.publisher.signals.logger.error'
)
as
mock_logger
:
...
@@ -54,6 +54,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
...
@@ -54,6 +54,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
def
test_create_course_run_in_studio
(
self
,
mock_access_token
):
# pylint: disable=unused-argument
def
test_create_course_run_in_studio
(
self
,
mock_access_token
):
# pylint: disable=unused-argument
organization
=
OrganizationFactory
()
organization
=
OrganizationFactory
()
partner
=
organization
.
partner
partner
=
organization
.
partner
start
=
datetime
.
datetime
.
utcnow
()
course_run_key
=
'course-v1:TestX+Testing101x+1T2017'
course_run_key
=
'course-v1:TestX+Testing101x+1T2017'
body
=
{
'id'
:
course_run_key
}
body
=
{
'id'
:
course_run_key
}
...
@@ -69,6 +70,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
...
@@ -69,6 +70,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
responses
.
add
(
responses
.
POST
,
url
,
json
=
body
,
status
=
200
)
responses
.
add
(
responses
.
POST
,
url
,
json
=
body
,
status
=
200
)
with
mock
.
patch
(
'course_discovery.apps.publisher.signals.logger.exception'
)
as
mock_logger
:
with
mock
.
patch
(
'course_discovery.apps.publisher.signals.logger.exception'
)
as
mock_logger
:
publisher_course_run
=
CourseRunFactory
(
publisher_course_run
=
CourseRunFactory
(
start
=
start
,
lms_course_id
=
None
,
lms_course_id
=
None
,
course__organizations
=
[
organization
]
course__organizations
=
[
organization
]
)
)
...
@@ -92,6 +94,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
...
@@ -92,6 +94,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
partner
=
organization
.
partner
partner
=
organization
.
partner
course_key
=
'{org}+{number}'
.
format
(
org
=
organization
.
key
,
number
=
number
)
course_key
=
'{org}+{number}'
.
format
(
org
=
organization
.
key
,
number
=
number
)
discovery_course_run
=
DiscoveryCourseRunFactory
(
course__partner
=
partner
,
course__key
=
course_key
)
discovery_course_run
=
DiscoveryCourseRunFactory
(
course__partner
=
partner
,
course__key
=
course_key
)
start
=
datetime
.
datetime
.
utcnow
()
course_run_key
=
'course-v1:TestX+Testing101x+1T2017'
course_run_key
=
'course-v1:TestX+Testing101x+1T2017'
body
=
{
'id'
:
course_run_key
}
body
=
{
'id'
:
course_run_key
}
...
@@ -110,6 +113,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
...
@@ -110,6 +113,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
responses
.
add
(
responses
.
POST
,
url
,
json
=
body
,
status
=
200
)
responses
.
add
(
responses
.
POST
,
url
,
json
=
body
,
status
=
200
)
publisher_course_run
=
CourseRunFactory
(
publisher_course_run
=
CourseRunFactory
(
start
=
start
,
lms_course_id
=
None
,
lms_course_id
=
None
,
course__organizations
=
[
organization
],
course__organizations
=
[
organization
],
course__number
=
number
course__number
=
number
...
@@ -128,6 +132,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
...
@@ -128,6 +132,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
def
test_create_course_run_in_studio_with_image_failure
(
self
,
__
,
___
):
# pylint: disable=unused-argument
def
test_create_course_run_in_studio_with_image_failure
(
self
,
__
,
___
):
# pylint: disable=unused-argument
organization
=
OrganizationFactory
()
organization
=
OrganizationFactory
()
partner
=
organization
.
partner
partner
=
organization
.
partner
start
=
datetime
.
datetime
.
utcnow
()
course_run_key
=
'course-v1:TestX+Testing101x+1T2017'
course_run_key
=
'course-v1:TestX+Testing101x+1T2017'
body
=
{
'id'
:
course_run_key
}
body
=
{
'id'
:
course_run_key
}
...
@@ -137,6 +142,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
...
@@ -137,6 +142,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
with
mock
.
patch
(
'course_discovery.apps.publisher.signals.logger.exception'
)
as
mock_logger
:
with
mock
.
patch
(
'course_discovery.apps.publisher.signals.logger.exception'
)
as
mock_logger
:
publisher_course_run
=
CourseRunFactory
(
publisher_course_run
=
CourseRunFactory
(
start
=
start
,
lms_course_id
=
None
,
lms_course_id
=
None
,
course__organizations
=
[
organization
]
course__organizations
=
[
organization
]
)
)
...
@@ -153,6 +159,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
...
@@ -153,6 +159,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
def
test_create_course_run_in_studio_with_image_api_failure
(
self
,
mock_access_token
):
def
test_create_course_run_in_studio_with_image_api_failure
(
self
,
mock_access_token
):
organization
=
OrganizationFactory
()
organization
=
OrganizationFactory
()
partner
=
organization
.
partner
partner
=
organization
.
partner
start
=
datetime
.
datetime
.
utcnow
()
course_run_key
=
'course-v1:TestX+Testing101x+1T2017'
course_run_key
=
'course-v1:TestX+Testing101x+1T2017'
body
=
{
'id'
:
course_run_key
}
body
=
{
'id'
:
course_run_key
}
...
@@ -169,6 +176,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
...
@@ -169,6 +176,7 @@ class TestCreateCourseRunInStudio(MockedStartEndDateTestCase):
with
mock
.
patch
(
'course_discovery.apps.publisher.signals.logger.exception'
)
as
mock_logger
:
with
mock
.
patch
(
'course_discovery.apps.publisher.signals.logger.exception'
)
as
mock_logger
:
publisher_course_run
=
CourseRunFactory
(
publisher_course_run
=
CourseRunFactory
(
start
=
start
,
lms_course_id
=
None
,
lms_course_id
=
None
,
course__organizations
=
[
organization
]
course__organizations
=
[
organization
]
)
)
...
...
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