payments views passing tests
This commit is contained in:
@@ -107,6 +107,8 @@ class mocked_canvas():
|
||||
def print_figure(*args, **kwargs):
|
||||
return True
|
||||
|
||||
# Mocked Dataprep
|
||||
|
||||
def mocked_fetchcperg(*args, **kwargs):
|
||||
df = pd.read_csv('rowers/tests/testdata/cpdataerg.csv')
|
||||
|
||||
@@ -156,6 +158,8 @@ def mocked_read_df_cols_sql_multiflex(ids, columns, convertnewtons=True):
|
||||
|
||||
return df, extracols
|
||||
|
||||
# Mocked Strava
|
||||
|
||||
def mocked_stravaexport(f2,workoutname,stravatoken,description='',
|
||||
activity_type='Rowing'):
|
||||
print "this is mocked strava export"
|
||||
@@ -172,6 +176,62 @@ class MockStravalibClient():
|
||||
def update_activity(*args, **kwargs):
|
||||
return StravaActivity()
|
||||
|
||||
# Mocked Braintree
|
||||
|
||||
## Higher level - unfortunately didn't succeed in mocking the gateway
|
||||
|
||||
def mock_create_customer(*args, **kwargs):
|
||||
return 121
|
||||
|
||||
def mock_make_payment(*args, **kwargs):
|
||||
return 15,''
|
||||
|
||||
def mock_update_subscription(*args, **kwargs):
|
||||
try:
|
||||
rower = args[0]
|
||||
data = args[1]
|
||||
planid = data['plan']
|
||||
plan = PaidPlan.objects.get(id=planid)
|
||||
amount = data['amount']
|
||||
|
||||
rower.paidplan = plan
|
||||
rower.planexpires = (datetime.datetime.now()+datetime.timedelta(days=365)).date()
|
||||
rower.clubsize = plan.clubsize
|
||||
rower.paymenttype = plan.paymenttype
|
||||
rower.rowerplan = plan.shortname
|
||||
rower.subscription_id = 12
|
||||
rower.save()
|
||||
except:
|
||||
amount = 20
|
||||
|
||||
return True,amount
|
||||
|
||||
def mock_create_subscription(*args, **kwargs):
|
||||
return mock_update_subscription(*args, **kwargs)
|
||||
|
||||
def mock_cancel_subscription(*args, **kwargs):
|
||||
themessages = []
|
||||
errormessages = []
|
||||
try:
|
||||
basicplans = PaidPlan.objects.filter(price=0,paymentprocessor='braintree')
|
||||
rower.paidplan = basicplans[0]
|
||||
rower.teamplanexpires = timezone.now()
|
||||
rower.planexpires = timezone.now()
|
||||
rower.clubsize = 0
|
||||
rower.rowerplan = 'basic'
|
||||
rower.subscription_id = None
|
||||
rower.save()
|
||||
themessages.append("Your plan was reset to basic")
|
||||
except:
|
||||
pass
|
||||
|
||||
return True, themessages,errormessages
|
||||
|
||||
def mock_mocktest(*args, **kwargs):
|
||||
return '121'
|
||||
|
||||
## Gateway stuff (not working)
|
||||
|
||||
class gatewayresult():
|
||||
def __init__(self,*args,**kwargs):
|
||||
self.is_success = kwargs.pop('is_success',True)
|
||||
@@ -309,7 +369,9 @@ def mocked_gateway(*args, **kwargs):
|
||||
|
||||
return MockBraintreeGateway()
|
||||
|
||||
|
||||
|
||||
# Mocked Rowingdata
|
||||
|
||||
class mocked_rowingdata(rowingdata):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(mocked_rowingdata).__init__(*args, **kwargs)
|
||||
@@ -354,7 +416,9 @@ class mocked_rowingdata(rowingdata):
|
||||
fig1 = figure.Figure(figsize(12,10))
|
||||
return fig1
|
||||
|
||||
|
||||
|
||||
# Mocked Requests
|
||||
|
||||
# to be done add polar mocks (for email processing)
|
||||
def mocked_requests(*args, **kwargs):
|
||||
with open('rowers/tests/testdata/c2jsonworkoutdata.txt','r') as infile:
|
||||
|
||||
Reference in New Issue
Block a user