Merge branch 'release/v10.09'
This commit is contained in:
@@ -22,6 +22,7 @@ import sqlalchemy as sa
|
|||||||
|
|
||||||
from rowsandall_app.settings import DATABASES
|
from rowsandall_app.settings import DATABASES
|
||||||
from rowsandall_app.settings_dev import DATABASES as DEV_DATABASES
|
from rowsandall_app.settings_dev import DATABASES as DEV_DATABASES
|
||||||
|
from rowsandall_app.settings_dev import use_sqlite
|
||||||
|
|
||||||
from rowers.utils import lbstoN
|
from rowers.utils import lbstoN
|
||||||
|
|
||||||
@@ -58,8 +59,13 @@ database_url = 'mysql://{user}:{password}@{host}:{port}/{database_name}'.format(
|
|||||||
|
|
||||||
database_name_dev = DEV_DATABASES['default']['NAME']
|
database_name_dev = DEV_DATABASES['default']['NAME']
|
||||||
|
|
||||||
|
database_url_debug = database_url
|
||||||
|
|
||||||
|
if use_sqlite:
|
||||||
database_url_debug = 'sqlite:///'+database_name_dev
|
database_url_debug = 'sqlite:///'+database_name_dev
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# mapping the DB column names to the CSV file column names
|
# mapping the DB column names to the CSV file column names
|
||||||
columndict = {
|
columndict = {
|
||||||
'time':'TimeStamp (sec)',
|
'time':'TimeStamp (sec)',
|
||||||
@@ -728,7 +734,7 @@ def fitnessmetric_to_sql(m,table='powertimefitnessmetric',debug=False,
|
|||||||
engine = create_engine(database_url, echo=False)
|
engine = create_engine(database_url, echo=False)
|
||||||
|
|
||||||
columns = ', '.join(m.keys())
|
columns = ', '.join(m.keys())
|
||||||
if debug:
|
if use_sqlite:
|
||||||
placeholders = ", ".join(["?"] * len(m))
|
placeholders = ", ".join(["?"] * len(m))
|
||||||
else:
|
else:
|
||||||
placeholders = ", ".join(["%s"] * len(m))
|
placeholders = ", ".join(["%s"] * len(m))
|
||||||
|
|||||||
@@ -1121,6 +1121,9 @@ def fitnessmetric_chart(fitnessmetrics,user,workoutmode='rower',startdate=None,
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
df = pd.DataFrame()
|
df = pd.DataFrame()
|
||||||
|
|
||||||
|
if df.empty:
|
||||||
|
return ["","no data"]
|
||||||
|
|
||||||
groups = df.groupby(by='date').max()
|
groups = df.groupby(by='date').max()
|
||||||
|
|
||||||
power4min = groups['power4min']
|
power4min = groups['power4min']
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class Command(BaseCommand):
|
|||||||
except Message.DoesNotExist:
|
except Message.DoesNotExist:
|
||||||
attachment.delete()
|
attachment.delete()
|
||||||
for rower in rowers:
|
for rower in rowers:
|
||||||
if extension == 'zip':
|
if 'zip' in extension:
|
||||||
try:
|
try:
|
||||||
zip_file = zipfile.ZipFile(attachment.document)
|
zip_file = zipfile.ZipFile(attachment.document)
|
||||||
for id,filename in enumerate(zip_file.namelist()):
|
for id,filename in enumerate(zip_file.namelist()):
|
||||||
|
|||||||
@@ -66,6 +66,67 @@ workout run
|
|||||||
w = ws[0]
|
w = ws[0]
|
||||||
self.assertEqual(w.workouttype,'Run')
|
self.assertEqual(w.workouttype,'Run')
|
||||||
|
|
||||||
|
@override_settings(TESTING=True)
|
||||||
|
class ZipEmailUpload(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
redis_connection.publish('tasks','KILL')
|
||||||
|
u = User.objects.create_user('john',
|
||||||
|
'sander@ds.ds',
|
||||||
|
'koeinsloot')
|
||||||
|
r = Rower.objects.create(user=u,gdproptin=True,
|
||||||
|
gdproptindate=timezone.now()
|
||||||
|
)
|
||||||
|
|
||||||
|
self.theadmin = UserFactory(is_staff=True)
|
||||||
|
self.rtheadmin = Rower.objects.create(user=self.theadmin,
|
||||||
|
birthdate = faker.profile()['birthdate'],
|
||||||
|
gdproptin=True,
|
||||||
|
gdproptindate=timezone.now(),
|
||||||
|
rowerplan='coach')
|
||||||
|
|
||||||
|
nu = datetime.datetime.now()
|
||||||
|
workoutsbox = Mailbox.objects.create(name='workouts1')
|
||||||
|
workoutsbox.save()
|
||||||
|
failbox = Mailbox.objects.create(name='Failed')
|
||||||
|
failbox.save()
|
||||||
|
|
||||||
|
m = Message(mailbox=workoutsbox,
|
||||||
|
from_header = u.email,
|
||||||
|
subject = "Sprint",
|
||||||
|
body = """
|
||||||
|
workout water
|
||||||
|
""")
|
||||||
|
m.save()
|
||||||
|
a2 = 'media/mailbox_attachments/zipfile.zip'
|
||||||
|
copy('rowers/tests/testdata/zipfile.zip',a2)
|
||||||
|
a = MessageAttachment(message=m,document=a2[6:])
|
||||||
|
a.save()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
for filename in os.listdir('media/mailbox_attachments'):
|
||||||
|
path = os.path.join('media/mailbox_attachments/',filename)
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
try:
|
||||||
|
os.remove(path)
|
||||||
|
except (IOError,FileNotFoundError,OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@patch('rowers.dataprep.create_engine')
|
||||||
|
@patch('rowers.polarstuff.get_polar_notifications')
|
||||||
|
@patch('rowers.c2stuff.requests.get', side_effect=mocked_requests)
|
||||||
|
@patch('rowers.c2stuff.requests.post', side_effect=mocked_requests)
|
||||||
|
def test_emailupload(
|
||||||
|
self, mocked_sqlalchemy,mocked_polar_notifications, mock_get, mock_post):
|
||||||
|
out = StringIO()
|
||||||
|
call_command('processemail', stdout=out,testing=True,mailbox='workouts1')
|
||||||
|
self.assertIn('Successfully processed email attachments',out.getvalue())
|
||||||
|
|
||||||
|
ws = Workout.objects.all()
|
||||||
|
|
||||||
|
self.assertEqual(len(ws),5)
|
||||||
|
w = ws[4]
|
||||||
|
self.assertEqual(w.name,'Sprint (5)')
|
||||||
|
|
||||||
|
|
||||||
@override_settings(TESTING=True)
|
@override_settings(TESTING=True)
|
||||||
class EmailBikeErgUpload(TestCase):
|
class EmailBikeErgUpload(TestCase):
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
Binary file not shown.
BIN
rowers/tests/testdata/zipfile.zip
vendored
BIN
rowers/tests/testdata/zipfile.zip
vendored
Binary file not shown.
@@ -27,7 +27,8 @@ if TESTING or use_sqlite:
|
|||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||||
'HOST': 'localhost',
|
'HOST': 'localhost',
|
||||||
},
|
'PASSWORD': 'roeidata',
|
||||||
|
'PORT': '3306', },
|
||||||
# 'TEST': {
|
# 'TEST': {
|
||||||
# 'CHARSET': 'utf8',
|
# 'CHARSET': 'utf8',
|
||||||
# 'COLLATION': 'utf8_general_ci',
|
# 'COLLATION': 'utf8_general_ci',
|
||||||
@@ -37,9 +38,7 @@ if TESTING or use_sqlite:
|
|||||||
# 'ENGINE': 'django.db.backends.mysql',
|
# 'ENGINE': 'django.db.backends.mysql',
|
||||||
# 'NAME': 'rowsanda_107501',
|
# 'NAME': 'rowsanda_107501',
|
||||||
# 'USER': 'rowsanda_107501',
|
# 'USER': 'rowsanda_107501',
|
||||||
# 'PASSWORD': 'roeidata',
|
|
||||||
# 'HOST': 'store3.rosti.cz',
|
|
||||||
# 'PORT': '3306',
|
|
||||||
# }
|
# }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user