Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
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
ecommerce
Commits
0cfcd935
Commit
0cfcd935
authored
May 17, 2016
by
Vedran Karačić
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #734 from edx/remove-mngmt-cmd
Remove voucher management command
parents
ceab5ccd
db444687
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
73 deletions
+0
-73
ecommerce/extensions/voucher/management/__init__.py
+0
-0
ecommerce/extensions/voucher/management/commands/__init__.py
+0
-0
ecommerce/extensions/voucher/management/commands/fix_single_use.py
+0
-30
ecommerce/extensions/voucher/tests/test_fix_single_use_command.py
+0
-43
No files found.
ecommerce/extensions/voucher/management/__init__.py
deleted
100644 → 0
View file @
ceab5ccd
ecommerce/extensions/voucher/management/commands/__init__.py
deleted
100644 → 0
View file @
ceab5ccd
ecommerce/extensions/voucher/management/commands/fix_single_use.py
deleted
100644 → 0
View file @
ceab5ccd
""" This command fixes SINGLE_USE vouchers."""
import
logging
from
django.core.management
import
BaseCommand
from
oscar.core.loading
import
get_model
logger
=
logging
.
getLogger
(
__name__
)
Voucher
=
get_model
(
'voucher'
,
'Voucher'
)
class
Command
(
BaseCommand
):
"""
Fix all SINGLE_USE vouchers.
Some SINGLE_USE vouchers may have been created with the wrong max_applications set.
This command sets their max_global_applications to the default value.
"""
ch
=
logging
.
StreamHandler
()
ch
.
setLevel
(
logging
.
DEBUG
)
logger
.
addHandler
(
ch
)
def
handle
(
self
,
*
args
,
**
options
):
vouchers
=
Voucher
.
objects
.
filter
(
usage
=
Voucher
.
SINGLE_USE
,
offers__max_global_applications
=
1
)
for
v
in
vouchers
:
offer
=
v
.
offers
.
first
()
logger
.
info
(
'Modifying Voucher
%
s.'
,
v
.
name
)
offer
.
max_global_applications
=
None
offer
.
save
()
ecommerce/extensions/voucher/tests/test_fix_single_use_command.py
deleted
100644 → 0
View file @
ceab5ccd
# encoding: utf-8
"""Contains the tests for fix_single_use command."""
from
django.core.management
import
call_command
from
mock
import
patch
from
oscar.core.loading
import
get_model
from
ecommerce.extensions.test.factories
import
prepare_voucher
from
ecommerce.tests.mixins
import
CouponMixin
from
ecommerce.tests.testcases
import
TestCase
Voucher
=
get_model
(
'voucher'
,
'Voucher'
)
COUPON_CODE
=
'COUPONTEST'
class
FixSingleUseVoucherTests
(
CouponMixin
,
TestCase
):
"""Tests the fix_single_use command."""
def
setUp
(
self
):
super
(
FixSingleUseVoucherTests
,
self
)
.
setUp
()
def
test_command_called_successfully
(
self
):
""" Verify command runs. """
with
patch
(
'ecommerce.extensions.voucher.management.commands.fix_single_use.Command'
)
as
mock_call_command
:
call_command
(
'fix_single_use'
)
self
.
assertTrue
(
mock_call_command
.
called
)
def
assert_command_execution
(
self
,
usage
,
max_usage
,
expected_before
,
expected_after
):
""" Assert offer max_global_applications value changed after the command call. """
voucher
,
__
=
prepare_voucher
(
code
=
COUPON_CODE
,
usage
=
usage
,
max_usage
=
max_usage
)
offer_before
=
voucher
.
offers
.
first
()
self
.
assertEqual
(
offer_before
.
max_global_applications
,
expected_before
)
call_command
(
'fix_single_use'
)
offer_after
=
voucher
.
offers
.
first
()
self
.
assertEqual
(
offer_after
.
max_global_applications
,
expected_after
)
def
test_offer_changed
(
self
):
""" Verify the offer has changed. """
self
.
assert_command_execution
(
Voucher
.
SINGLE_USE
,
1
,
1
,
None
)
def
test_offer_unchanged
(
self
):
""" Verify voucher other than SINGLE_USE are left unaffected. """
self
.
assert_command_execution
(
Voucher
.
ONCE_PER_CUSTOMER
,
1
,
1
,
1
)
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