tested
This commit is contained in:
@@ -128,6 +128,67 @@ workout water
|
|||||||
self.assertEqual(w.name,'Sprint (5)')
|
self.assertEqual(w.name,'Sprint (5)')
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(TESTING=True)
|
||||||
|
class EmailUniCodeUpload(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='workouts2')
|
||||||
|
workoutsbox.save()
|
||||||
|
failbox = Mailbox.objects.create(name='Failed')
|
||||||
|
failbox.save()
|
||||||
|
|
||||||
|
m = Message(mailbox=workoutsbox,
|
||||||
|
from_header = u.email,
|
||||||
|
subject = "Třeboň",
|
||||||
|
body = """
|
||||||
|
workout water
|
||||||
|
""")
|
||||||
|
m.save()
|
||||||
|
a2 = 'media/mailbox_attachments/colin4a.csv'
|
||||||
|
copy('rowers/tests/testdata/emails/colin.csv',a2)
|
||||||
|
a = MessageAttachment(message=m,document=a2[6:])
|
||||||
|
a.save()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
filename = 'colin4a.csv'
|
||||||
|
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='workouts2')
|
||||||
|
self.assertIn('Successfully processed email attachments',out.getvalue())
|
||||||
|
|
||||||
|
ws = Workout.objects.filter(name="Třeboň")
|
||||||
|
|
||||||
|
self.assertEqual(len(ws),1)
|
||||||
|
w = ws[0]
|
||||||
|
self.assertEqual(w.workouttype,'water')
|
||||||
|
|
||||||
@override_settings(TESTING=True)
|
@override_settings(TESTING=True)
|
||||||
class EmailBikeErgUpload(TestCase):
|
class EmailBikeErgUpload(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user