Пример #1
0
    def test_should_resend_email_with_new_key_if_is_not_confirmed(self, requests_mock):
        # Given: database
        self.db.users.insert(test_user(confirmed=False))

        # When: Post to users
        self.register_test_user()

        # Then
        assert_mailgun(requests_mock, EMAIL_ADDRESS, "Welcome to Warsjawa!")
    def test_should_send_emails_for_workshop_when_user_selects_workshop(self, requests_mock):
        # Given:
        self.user_and_workshop_exists()

        # When:
        self.user_selects_workshop()

        # Then
        assert_mailgun(requests_mock, subject=FIRST_MAIL_SUBJECT)
Пример #3
0
    def test_should_send_email_and_return_correct_status_code(self, requests_mock):
        # Given: Empty database

        # When: Post to users
        rv = self.register_test_user()

        # Then response is OK
        self.assertEqual(rv.status_code, 201)
        assert_mailgun(requests_mock, to=EMAIL_ADDRESS)
Пример #4
0
    def test_should_allow_confirmation_by_sending_email_if_user_is_not_confirmed(self, requests_mock):
        self.db.users.insert(test_user(confirmed=False))

        # When: Confirm user
        rv = self.confirm_test_user()

        # Then
        self.assertEqual(rv.status_code, 200)
        assert_mailgun(requests_mock, EMAIL_ADDRESS, "Warsjawa - additional informations")
    def test_should_allow_confirmation_by_sending_email_if_user_is_not_confirmed(
            self, requests_mock):
        self.db.users.insert(TEST_NOT_CONFIRMED_USER_IN_DB)

        # When: Confirm user
        rv = self.confirm_test_user()

        # Then
        self.assertEqual(rv.status_code, 201)
        assert_mailgun(requests_mock, EMAIL_ADDRESS, "You are confirmed now")
    def test_should_resend_email_with_new_key_if_is_not_confirmed(
            self, requests_mock):
        # Given: database
        self.db.users.insert(TEST_NOT_CONFIRMED_USER_IN_DB)

        # When: Post to users
        self.register_test_user()

        # Then
        assert_mailgun(requests_mock, EMAIL_ADDRESS, "Hello")
Пример #7
0
    def test_should_send_emails_for_workshop_when_user_selects_workshop(
            self, requests_mock):
        # Given:
        self.user_and_workshop_exists()

        # When:
        self.user_selects_workshop()

        # Then
        assert_mailgun(requests_mock, subject=FIRST_MAIL_SUBJECT)
    def test_should_save_incoming_emails_in_workshop_and_forward_to_users(self, requests_mock):
        # Given a database with one workshop
        self.db.workshops.insert(WORKSHOP_IN_DB)

        # When
        rv = self.mailgun_sends_email()

        # Then
        self.assertEqual(1, len(self.db.workshops.find_one()['emails']))
        assert_mailgun(requests_mock, to=USER_EMAIL_ADDRESS, subject="test")
Пример #9
0
    def test_should_deny_confirmation_by_sending_email_if_user_already_confirmed(self, requests_mock):
        # Given: database
        self.db.users.insert(test_user(confirmed=True))

        # When: Confirm user
        rv = self.confirm_test_user()

        # Then Return code is 304 and e-mail is sent
        self.assertEqual(rv.status_code, 304)
        assert_mailgun(requests_mock, EMAIL_ADDRESS, "You can not confirm twice")
Пример #10
0
    def test_should_send_deny_email_if_already_registered(self, requests_mock):
        # Given: database
        self.db.users.insert(test_user(confirmed=True))

        # When: Post to users
        rv = self.register_test_user()

        # Then key is without change
        self.assertEqual(rv.status_code, 304)
        assert_mailgun(requests_mock, EMAIL_ADDRESS, "We've got a problem here !")
    def test_should_save_incoming_emails_in_workshop_and_forward_to_users(self, requests_mock):
        # Given a database with one workshop
        self.db.workshops.insert(workshop_in_db(with_user=True, with_mail=False))
        self.db.users.insert(user_in_db(confirmed=True))

        # When
        rv = self.mailgun_sends_email()

        # Then
        self.assertEqual(1, len(self.db.workshops.find_one()['emails']))
        self.assertEqual(1, requests_mock.post.call_count)
        assert_mailgun(requests_mock, to=USER_EMAIL_ADDRESS, subject='Warsjawa - test_workshop: %s' % SECOND_MAIL_SUBJECT)
    def test_should_not_send_emails_already_sent_to_this_user(self, requests_mock):
        # Given:
        self.user_and_workshop_exists()
        self.user_selects_workshop()
        self.user_deselects_workshop()
        self.new_workshop_email_is_registered()

        # When:
        self.user_selects_workshop()

        # Then
        self.assertEqual(2, requests_mock.post.call_count)
        assert_mailgun(requests_mock, subject=SECOND_MAIL_SUBJECT)
Пример #13
0
    def test_should_not_send_emails_already_sent_to_this_user(
            self, requests_mock):
        # Given:
        self.user_and_workshop_exists()
        self.user_selects_workshop()
        self.user_deselects_workshop()
        self.new_workshop_email_is_registered()

        # When:
        self.user_selects_workshop()

        # Then
        self.assertEqual(2, requests_mock.post.call_count)
        assert_mailgun(requests_mock, subject=SECOND_MAIL_SUBJECT)
    def test_should_save_incoming_emails_in_workshop_and_forward_to_users(
            self, requests_mock):
        # Given a database with one workshop
        self.db.workshops.insert(
            workshop_in_db(with_user=True, with_mail=False))
        self.db.users.insert(user_in_db(confirmed=True))

        # When
        rv = self.mailgun_sends_email()

        # Then
        self.assertEqual(1, len(self.db.workshops.find_one()['emails']))
        self.assertEqual(1, requests_mock.post.call_count)
        assert_mailgun(requests_mock,
                       to=USER_EMAIL_ADDRESS,
                       subject='Warsjawa - test_workshop: %s' %
                       SECOND_MAIL_SUBJECT)