test otw testpower
This commit is contained in:
@@ -1839,6 +1839,7 @@ def handle_otwsetpower(self,f1, boattype, boatclass, coastalbrand, weightvalue,
|
||||
job = self.request
|
||||
job_id = job.id
|
||||
|
||||
|
||||
if 'jobkey' in kwargs:
|
||||
job_id = kwargs.pop('jobkey')
|
||||
if 'ps' in kwargs:
|
||||
|
||||
@@ -58,6 +58,30 @@ redis_connection = StrictRedis()
|
||||
|
||||
from django_mailbox.models import Mailbox,MessageAttachment,Message
|
||||
|
||||
def mocked_grpc(*args, **kwargs):
|
||||
class insecure_channel:
|
||||
def __init__(*args,**kwargs):
|
||||
pass
|
||||
|
||||
class channel_ready_future:
|
||||
def __init__(*args,**kwargs):
|
||||
pass
|
||||
|
||||
def result(self,*args,**kwargs):
|
||||
pass
|
||||
|
||||
class Result:
|
||||
def __init__(*args,**kwargs):
|
||||
self.result = 1
|
||||
|
||||
class calculator_pb2_grpc:
|
||||
def PowerStub(*args,**kwargs):
|
||||
def __init__(*args,**kwargs):
|
||||
pass
|
||||
|
||||
def CalcPower(*args,**kwargs):
|
||||
return Result()
|
||||
|
||||
def mocked_send_template_email(*args,**kwargs):
|
||||
return 1
|
||||
|
||||
|
||||
@@ -10,6 +10,17 @@ import pandas as pd
|
||||
nu = datetime.datetime.now()
|
||||
from rowers import tasks
|
||||
|
||||
|
||||
class fakejob:
|
||||
def __init__(self):
|
||||
self.id = 1
|
||||
|
||||
class fakerequest:
|
||||
def __init__(self):
|
||||
self.id = 1
|
||||
self.job = fakejob()
|
||||
|
||||
|
||||
# asynchronous tasks
|
||||
class AsyncTaskTests(TestCase):
|
||||
def setUp(self):
|
||||
@@ -280,3 +291,23 @@ class AsyncTaskTests(TestCase):
|
||||
|
||||
res = tasks.handle_c2_import_stroke_data(c2token,c2id,workoutid,starttimeunix,csvfilename)
|
||||
self.assertEqual(res,1)
|
||||
|
||||
@patch('rowers.tasks.grpc',side_effect=mocked_grpc)
|
||||
@patch('rowers.tasks.send_template_email',side_effect=mocked_send_template_email)
|
||||
def test_handle_otwsetpower(self,mocked_send_template_email,mocked_grpc):
|
||||
f1 = result = get_random_file(filename='rowers/tests/testdata/sprintervals.csv')['filename']
|
||||
boattype = '1x'
|
||||
boatclass = 'water'
|
||||
coastalbrand = 'other'
|
||||
weightvalue = 80.
|
||||
first_name = self.u.first_name
|
||||
last_name = self.u.last_name
|
||||
email = self.u.email
|
||||
workoutid = self.wwater.id
|
||||
job = fakerequest()
|
||||
|
||||
res = tasks.handle_otwsetpower(f1,boattype,boatclass,coastalbrand,
|
||||
weightvalue,first_name,last_name,email,workoutid,
|
||||
jobkey='23')
|
||||
|
||||
self.assertEqual(res,1)
|
||||
|
||||
1152
rowers/tests/testdata/sprintervals.csv
vendored
Normal file
1152
rowers/tests/testdata/sprintervals.csv
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user