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
1bb23a13
Commit
1bb23a13
authored
Oct 26, 2017
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move test_site_config into the schedules management command base test class
parent
81da729a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
105 deletions
+50
-105
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+0
-50
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
+0
-55
openedx/core/djangoapps/schedules/management/commands/tests/tools.py
+50
-0
No files found.
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
View file @
1bb23a13
...
...
@@ -83,56 +83,6 @@ class TestSendRecurringNudge(ScheduleBaseEmailTestBase):
@patch.object
(
tasks
,
'ace'
)
@patch.object
(
tested_task
,
'async_send_task'
)
@ddt.data
(
(([
'filtered_org'
],
[],
1
)),
(([],
[
'filtered_org'
],
2
))
)
@ddt.unpack
def
test_site_config
(
self
,
this_org_list
,
other_org_list
,
expected_message_count
,
mock_schedule_send
,
mock_ace
):
filtered_org
=
'filtered_org'
unfiltered_org
=
'unfiltered_org'
this_config
=
SiteConfigurationFactory
.
create
(
values
=
{
'course_org_filter'
:
this_org_list
})
other_config
=
SiteConfigurationFactory
.
create
(
values
=
{
'course_org_filter'
:
other_org_list
})
for
config
in
(
this_config
,
other_config
):
ScheduleConfigFactory
.
create
(
site
=
config
.
site
)
user1
=
UserFactory
.
create
(
id
=
resolvers
.
RECURRING_NUDGE_NUM_BINS
)
user2
=
UserFactory
.
create
(
id
=
resolvers
.
RECURRING_NUDGE_NUM_BINS
*
2
)
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
44
,
30
,
tzinfo
=
pytz
.
UTC
),
enrollment__course__org
=
filtered_org
,
enrollment__user
=
user1
,
)
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
44
,
30
,
tzinfo
=
pytz
.
UTC
),
enrollment__course__org
=
unfiltered_org
,
enrollment__user
=
user1
,
)
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
44
,
30
,
tzinfo
=
pytz
.
UTC
),
enrollment__course__org
=
unfiltered_org
,
enrollment__user
=
user2
,
)
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
expected_queries
=
NUM_QUERIES_WITH_MATCHES
if
not
this_org_list
:
expected_queries
+=
NUM_QUERIES_NO_ORG_LIST
with
self
.
assertNumQueries
(
expected_queries
,
table_blacklist
=
WAFFLE_TABLES
):
self
.
tested_task
.
apply
(
kwargs
=
dict
(
site_id
=
this_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
0
))
self
.
assertEqual
(
mock_schedule_send
.
apply_async
.
call_count
,
expected_message_count
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
@patch.object
(
tasks
,
'ace'
)
@patch.object
(
tested_task
,
'async_send_task'
)
def
test_multiple_enrollments
(
self
,
mock_schedule_send
,
mock_ace
):
user
=
UserFactory
.
create
()
schedules
=
[
...
...
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
View file @
1bb23a13
...
...
@@ -77,61 +77,6 @@ class TestUpgradeReminder(ScheduleBaseEmailTestBase):
@patch.object
(
tasks
,
'ace'
)
@patch.object
(
tested_task
,
'async_send_task'
)
@ddt.data
(
(([
'filtered_org'
],
[],
1
)),
(([],
[
'filtered_org'
],
2
))
)
@ddt.unpack
def
test_site_config
(
self
,
this_org_list
,
other_org_list
,
expected_message_count
,
mock_schedule_send
,
mock_ace
):
filtered_org
=
'filtered_org'
unfiltered_org
=
'unfiltered_org'
this_config
=
SiteConfigurationFactory
.
create
(
values
=
{
'course_org_filter'
:
this_org_list
})
other_config
=
SiteConfigurationFactory
.
create
(
values
=
{
'course_org_filter'
:
other_org_list
})
for
config
in
(
this_config
,
other_config
):
ScheduleConfigFactory
.
create
(
site
=
config
.
site
)
user1
=
UserFactory
.
create
(
id
=
resolvers
.
UPGRADE_REMINDER_NUM_BINS
)
user2
=
UserFactory
.
create
(
id
=
resolvers
.
UPGRADE_REMINDER_NUM_BINS
*
2
)
ScheduleFactory
.
create
(
upgrade_deadline
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
44
,
30
,
tzinfo
=
pytz
.
UTC
),
enrollment__course__org
=
filtered_org
,
enrollment__course__self_paced
=
True
,
enrollment__user
=
user1
,
)
ScheduleFactory
.
create
(
upgrade_deadline
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
44
,
30
,
tzinfo
=
pytz
.
UTC
),
enrollment__course__org
=
unfiltered_org
,
enrollment__course__self_paced
=
True
,
enrollment__user
=
user1
,
)
ScheduleFactory
.
create
(
upgrade_deadline
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
44
,
30
,
tzinfo
=
pytz
.
UTC
),
enrollment__course__org
=
unfiltered_org
,
enrollment__course__self_paced
=
True
,
enrollment__user
=
user2
,
)
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
course_switch_queries
=
1
org_switch_queries
=
1
expected_queries
=
NUM_QUERIES_FIRST_MATCH
+
course_switch_queries
+
org_switch_queries
if
not
this_org_list
:
expected_queries
+=
NUM_QUERIES_NO_ORG_LIST
with
self
.
assertNumQueries
(
expected_queries
,
table_blacklist
=
WAFFLE_TABLES
):
self
.
tested_task
.
apply
(
kwargs
=
dict
(
site_id
=
this_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
0
))
self
.
assertEqual
(
mock_schedule_send
.
apply_async
.
call_count
,
expected_message_count
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
@patch.object
(
tasks
,
'ace'
)
@patch.object
(
tested_task
,
'async_send_task'
)
def
test_multiple_enrollments
(
self
,
mock_schedule_send
,
mock_ace
):
user
=
UserFactory
.
create
()
schedules
=
[
...
...
openedx/core/djangoapps/schedules/management/commands/tests/tools.py
View file @
1bb23a13
...
...
@@ -15,6 +15,7 @@ from openedx.core.djangoapps.schedules import resolvers, tasks
from
openedx.core.djangoapps.schedules.tests.factories
import
ScheduleConfigFactory
,
ScheduleFactory
from
openedx.core.djangoapps.waffle_utils.testutils
import
WAFFLE_TABLES
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
,
FilteredQueryCountMixin
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
...
@@ -214,3 +215,52 @@ class ScheduleBaseEmailTestBase(SharedModuleStoreTestCase):
self
.
assertTrue
(
mock_apply_async
.
called
)
else
:
self
.
assertFalse
(
mock_apply_async
.
called
)
@patch.object
(
tasks
,
'ace'
)
@ddt.data
(
(([
'filtered_org'
],
[],
1
)),
(([],
[
'filtered_org'
],
2
))
)
@ddt.unpack
def
test_site_config
(
self
,
this_org_list
,
other_org_list
,
expected_message_count
,
mock_ace
):
filtered_org
=
'filtered_org'
unfiltered_org
=
'unfiltered_org'
this_config
=
SiteConfigurationFactory
.
create
(
values
=
{
'course_org_filter'
:
this_org_list
})
other_config
=
SiteConfigurationFactory
.
create
(
values
=
{
'course_org_filter'
:
other_org_list
})
for
config
in
(
this_config
,
other_config
):
ScheduleConfigFactory
.
create
(
site
=
config
.
site
)
user1
=
UserFactory
.
create
(
id
=
self
.
tested_task
.
num_bins
)
user2
=
UserFactory
.
create
(
id
=
self
.
tested_task
.
num_bins
*
2
)
current_day
,
offset
,
target_day
=
self
.
_get_dates
()
ScheduleFactory
.
create
(
upgrade_deadline
=
target_day
,
start
=
target_day
,
enrollment__course__org
=
filtered_org
,
enrollment__course__self_paced
=
True
,
enrollment__user
=
user1
,
)
ScheduleFactory
.
create
(
upgrade_deadline
=
target_day
,
start
=
target_day
,
enrollment__course__org
=
unfiltered_org
,
enrollment__course__self_paced
=
True
,
enrollment__user
=
user1
,
)
ScheduleFactory
.
create
(
upgrade_deadline
=
target_day
,
start
=
target_day
,
enrollment__course__org
=
unfiltered_org
,
enrollment__course__self_paced
=
True
,
enrollment__user
=
user2
,
)
with
patch
.
object
(
self
.
tested_task
,
'async_send_task'
)
as
mock_schedule_send
:
self
.
tested_task
.
apply
(
kwargs
=
dict
(
site_id
=
this_config
.
site
.
id
,
target_day_str
=
serialize
(
target_day
),
day_offset
=
offset
,
bin_num
=
0
))
self
.
assertEqual
(
mock_schedule_send
.
apply_async
.
call_count
,
expected_message_count
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
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