def submission1(): three_days_ago = helper.get_date_time( datetime.now() - timedelta(days=3)) submission = Submission() submission.id = str(uuid4()) submission.mail = "*****@*****.**" submission.submission_date = three_days_ago return submission
def session(item, submission_id): session = get_db_session(True, None) submission = Submission() submission.id = submission_id submission.mail = "*****@*****.**" submission.item = item session.add(item) session.add(submission) session.commit() return session
def test_mail_notification(item, submission_id, monkeypatch): monkeypatch.setenv("STAGE", "dev") from review_service import notifications conn = boto3.client("ses", region_name="eu-central-1") conn.verify_email_identity(EmailAddress="*****@*****.**") with Session() as session: submission = Submission() submission.id = submission_id submission.mail = "*****@*****.**" submission.item = item session.add(item) session.add(submission) session.commit() notifications.notify_users(session, item) send_quota = conn.get_send_quota() sent_count = int(send_quota["SentLast24Hours"]) assert sent_count == 0 event = {'pathParameters': {'submission_id': submission_id}} response = confirm_submission(event, None) assert response['statusCode'] == 200 assert response['headers'][ 'content-type'] == 'text/html; charset=utf-8' assert 'Mail-Adresse erfolgreich bestätigt!' in response['body'] assert 'https://dev.codetekt.org' in response['body'] notifications.notify_users(session, item) send_quota = conn.get_send_quota() sent_count = int(send_quota["SentLast24Hours"]) assert sent_count == 1 message = ses_backend.sent_messages[0] assert '*****@*****.**' in message.destinations['ToAddresses'] assert 'Dein Fall wurde gelöst' in message.body assert '1.0' in message.body assert 'nicht vertrauenswürdig' in message.body
def test_mail_confirmation(submission_id, item, monkeypatch): monkeypatch.setenv("STAGE", "dev") from submission_service import submit_item with Session() as session: submission = Submission() submission.id = submission_id submission.mail = "*****@*****.**" submission.item = item session.add(item) session.add(submission) session.commit() submission = session.query(Submission).filter( Submission.id == submission_id).one() # Add you mail adress here in local testing mode submission.mail = "*****@*****.**" session.merge(submission) session.commit() submit_item.send_confirmation_mail(submission)
def submission(): submission = Submission() submission.id = str(uuid4()) submission.mail = "*****@*****.**" submission.submission_date = func.now() return submission