failed tests
This commit is contained in:
@@ -128,6 +128,67 @@ workout bikeerg
|
|||||||
w = ws[0]
|
w = ws[0]
|
||||||
self.assertEqual(w.workouttype,'bikeerg')
|
self.assertEqual(w.workouttype,'bikeerg')
|
||||||
|
|
||||||
|
@override_settings(TESTING=True)
|
||||||
|
class EmailBikeUpload(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='workouts')
|
||||||
|
workoutsbox.save()
|
||||||
|
failbox = Mailbox.objects.create(name='Failed')
|
||||||
|
failbox.save()
|
||||||
|
|
||||||
|
m = Message(mailbox=workoutsbox,
|
||||||
|
from_header = u.email,
|
||||||
|
subject = "bike",
|
||||||
|
body = """
|
||||||
|
workout bike
|
||||||
|
""")
|
||||||
|
m.save()
|
||||||
|
a2 = 'media/mailbox_attachments/colin3.csv'
|
||||||
|
copy('rowers/tests/testdata/emails/colin.csv',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)
|
||||||
|
self.assertIn('Successfully processed email attachments',out.getvalue())
|
||||||
|
|
||||||
|
ws = Workout.objects.filter(name="bikeerg")
|
||||||
|
|
||||||
|
self.assertEqual(len(ws),1)
|
||||||
|
w = ws[0]
|
||||||
|
self.assertEqual(w.workouttype,'bike')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#@pytest.mark.django_db
|
#@pytest.mark.django_db
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user