コード例 #1
0
ファイル: test_users.py プロジェクト: WeAreWizards/proppyweb
    def test_ok(self):
        with mail.record_messages() as outbox:
            _, status_code = self.post_json("/request-reset-password", {"email": self.user.email})

            self.assertEqual(len(outbox), 1)
            self.assertIn("Reset", outbox[0].subject)
            self.assertEqual(status_code, 200)
コード例 #2
0
ファイル: test_users.py プロジェクト: WeAreWizards/proppyweb
 def test_resend_activation_mail_already_active(self):
     u = UserFactory(email=self.first_user["email"])
     with mail.record_messages() as outbox:
         data, status_code = self.post_json(
             "/resend-activation-email", {"email": u.email}
         )
         self.assertEqual(status_code, 400)
         self.assertEqual(len(outbox), 0)
コード例 #3
0
ファイル: test_users.py プロジェクト: WeAreWizards/proppyweb
    def test_already_exists(self):
        with mail.record_messages() as outbox:
            data, status_code = self.post_json(
                "/invites", {"email": self.user.email}, user=self.user
            )

            self.assertEqual(status_code, 400)
            self.assertEqual(len(outbox), 0)
コード例 #4
0
ファイル: test_users.py プロジェクト: WeAreWizards/proppyweb
 def test_resend_activation_mail_ok(self):
     u = UserFactory(email=self.first_user["email"], activation_token=b'ere')
     with mail.record_messages() as outbox:
         data, status_code = self.post_json(
             "/resend-activation-email", {"email": u.email}
         )
         self.assertEqual(status_code, 200)
         self.assertEqual(len(outbox), 1)
         self.assertIn("Activate", outbox[0].subject)
コード例 #5
0
ファイル: test_users.py プロジェクト: WeAreWizards/proppyweb
    def test_resend_fail_different_company(self):
        with mail.record_messages() as outbox:
            email = UserFactory(activation_token=b'1212').email
            data, status_code = self.post_json(
                "/resend-invite", {"email": email}, user=self.user
            )

            self.assertEqual(status_code, 404)
            self.assertEqual(len(outbox), 0)
コード例 #6
0
ファイル: test_users.py プロジェクト: WeAreWizards/proppyweb
    def test_resend_fail_already_active(self):
        with mail.record_messages() as outbox:
            email = UserFactory(company=self.user.company).email
            data, status_code = self.post_json(
                "/resend-invite", {"email": email}, user=self.user
            )

            self.assertEqual(status_code, 400)
            self.assertEqual(len(outbox), 0)
コード例 #7
0
 def test_disabled_user_dont_receive_mails(self):
     UserFactory(disabled=True, company=self.user.company)
     with mail.record_messages() as outbox:
         data = dict(blockUid=self.p.blocks.all()[0].uid,
                     comment="look a comment",
                     username="******")
         self.post_json(self.url, data)
         self.assertEqual(len(outbox), 1)
         self.assertSetEqual(outbox[0].send_to, {self.user.email})
コード例 #8
0
ファイル: test_users.py プロジェクト: WeAreWizards/proppyweb
    def test_resend_ok(self):
        with mail.record_messages() as outbox:
            email = UserFactory(company=self.user.company, activation_token=b'1212').email
            data, status_code = self.post_json(
                "/resend-invite", {"email": email}, user=self.user
            )

            self.assertEqual(status_code, 200)
            self.assertEqual(len(outbox), 1)
            self.assertIn("invited", outbox[0].subject)
コード例 #9
0
 def test_email_share_proposal_no_duplicate_contacts(self):
     SharedProposalFactory(version=1, proposal=self.p)
     with mail.record_messages() as outbox:
         self.c.contacts = ["*****@*****.**"]
         _, status = self.post_json(self.email_url,
                                    self.email,
                                    user=self.user)
         self.assertEqual(status, 200)
         self.assertListEqual(sorted(list(outbox[0].send_to)),
                              sorted(["*****@*****.**", self.user.email]))
         self.assertEqual(len(self.p.client.contacts), 1)
コード例 #10
0
ファイル: test_users.py プロジェクト: WeAreWizards/proppyweb
    def test_ok(self):
        with mail.record_messages() as outbox:
            email = "*****@*****.**"
            data, status_code = self.post_json(
                "/invites", {"email": email}, user=self.user
            )

            self.assertEqual(status_code, 201)
            self.assertEqual(len(outbox), 1)
            self.assertIn("invited", outbox[0].subject)
            u = User.query.filter_by(email=email).first()
            self.assertNotEqual(u.activation_token, b"")
            self.assertNotEqual(u.password, b"")
コード例 #11
0
    def test_start_thread_logged_in(self):
        with mail.record_messages() as outbox:
            data = dict(
                blockUid=self.p.blocks.all()[0].uid,
                comment="look a comment",
            )
            _, status = self.post_json(self.url, data, user=self.user)
            self.assertEquals(status, 201)
            self.assertEquals(self.shared.comment_threads.count(), 1)

            thread = self.shared.comment_threads.first()
            self.assertEqual(thread.comments.first().username,
                             self.user.username)
            self.assertFalse(thread.comments.first().from_client)
            # No mail for logged in users
            self.assertEqual(len(outbox), 0)
コード例 #12
0
    def test_start_thread_anonymous(self):
        with mail.record_messages() as outbox:
            data = dict(blockUid=self.p.blocks.all()[0].uid,
                        comment="look a comment",
                        username="******")
            _, status = self.post_json(self.url, data)

            self.assertEquals(status, 201)
            self.assertEquals(self.shared.comment_threads.count(), 1)

            thread = self.shared.comment_threads.first()
            self.assertEqual(thread.comments.first().username,
                             data["username"])
            self.assertTrue(thread.comments.first().from_client)

            self.assertEqual(len(outbox), 1)
            self.assertSetEqual(outbox[0].send_to, {self.user.email})
コード例 #13
0
ファイル: test_users.py プロジェクト: WeAreWizards/proppyweb
    def test_ok(self):
        with mail.record_messages() as outbox:
            data, status_code = self.post_json("/users", self.first_user)
            user = User.query.first()
            company = Company.query.first()

            self.assertEqual(len(outbox), 1)
            self.assertIn("Activate", outbox[0].subject)
            self.assertEqual(status_code, 201)
            self.assertEqual(data["user"]["username"], self.first_user["username"])
            self.assertEqual(company.name, self.first_user["companyName"])
            self.assertTrue(user.verify_password("password"))
            self.assertEqual(data["user"]["companyId"], company.id)
            # The onboarding one
            self.assertEqual(company.proposals.count(), 1)

            self.assertEqual(user.utm_source, "not-set")
コード例 #14
0
    def test_can_sign_shared_proposal_anon(self):
        self.shared.blocks.append(self.sig_block)

        with mail.record_messages() as outbox:
            _, code = self.post_json(self.url, self.data)

            self.assertEqual(code, 200)
            self.assertEqual(self.p.signature.count(), 1)
            # It should update the signature block
            signed_block = self.shared.get_signature_block()
            self.assertEqual(signed_block.data["signature"],
                             self.data["signature"])
            self.assertEqual(signed_block.data["name"], self.data["name"])
            self.assertIn("hash", signed_block.data)
            self.assertEqual(self.p.status, "won")
            self.assertEqual(len(outbox), 1)
            self.assertIn(self.p.title, outbox[0].body)
            self.assertIn(self.data["name"], outbox[0].body)
コード例 #15
0
    def test_email_share_proposal(self):
        SharedProposalFactory(version=1, proposal=self.p)
        with mail.record_messages() as outbox:
            _, status = self.post_json(self.email_url,
                                       self.email,
                                       user=self.user)

            self.assertEqual(status, 200)
            self.assertEqual(self.p.shared_proposals.count(), 1)
            shared = self.p.shared_proposals.first()
            self.assertEqual(shared.version, 1)
            self.assertEqual(shared.blocks.count(), self.p.blocks.count())
            self.assertEqual(len(outbox), 1)
            self.assertIn(self.p.share_uid, outbox[0].body)
            self.assertIn("Yolo", outbox[0].body)
            self.assertEqual(len(self.p.client.contacts), 1)
            self.assertEqual(self.p.client.contacts[0], "*****@*****.**")
            self.assertEqual(shared.subject, self.email["subject"])
            self.assertEqual(shared.from_name, self.email["from"])
            self.assertEqual(shared.body, self.email["body"])
コード例 #16
0
    def test_append_comment_to_thread_anonymous(self):
        with mail.record_messages() as outbox:
            block = self.shared.blocks.all()[0]
            self.shared.comment_threads.append(
                SharedCommentThread(block_id=block.id, block_uid=block.uid))
            thread = self.shared.comment_threads.all()[0]
            data = dict(threadId=thread.id,
                        comment="look a comment",
                        username="******")

            self.assertEquals(thread.comments.count(), 0)
            _, status = self.post_json(self.url, data)

            self.assertEquals(status, 201)
            self.assertEquals(thread.comments.count(), 1)
            self.assertEquals(thread.comments.first().username,
                              data["username"])

            self.assertEqual(len(outbox), 1)
            self.assertSetEqual(outbox[0].send_to, {self.user.email})
コード例 #17
0
 def test_send_emails(self):
     with mail.record_messages() as outbox:
         send_trial_end_emails_command()
         self.assertEqual(len(outbox), 1)
コード例 #18
0
 def test_basic_sharing_works(self):
     with mail.record_messages() as outbox:
         _, status = self.post_json(self.url, {}, user=self.user)
         self.assertEqual(status, 200)
         self.assertEqual(self.p.shared_proposals.count(), 1)
         self.assertEqual(len(outbox), 0)