Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
孙永强 committed Aug 15, 2024
1 parent aba4e22 commit b0c453f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/api/endpoints/test_send_upload_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ def test_can_send_email_configured(self):

resp = self.client.post(url, data)
self.assertEqual(200, resp.status_code)
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(len(mail.outbox), 2)
json_resp = json.loads(resp.content)
assert json_resp['success'][0] == self.admin.email
assert json_resp['failed'][0]['email'] == invalid_email
assert mail.outbox[0].from_email == '[email protected]'
assert mail.outbox[1].from_email == '[email protected]'

@patch('seahub.utils.IS_EMAIL_CONFIGURED', True)
@patch('seahub.api2.endpoints.send_upload_link_email.IS_EMAIL_CONFIGURED', True)
Expand All @@ -54,10 +54,10 @@ def test_can_send_email_rewrite(self):

resp = self.client.post(url, data)
self.assertEqual(200, resp.status_code)
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(len(mail.outbox), 2)
json_resp = json.loads(resp.content)
assert json_resp['success'][0] == self.admin.email
assert mail.outbox[0].extra_headers['Reply-to'] == self.user.email
assert mail.outbox[1].extra_headers['Reply-to'] == self.user.email

@patch('seahub.utils.IS_EMAIL_CONFIGURED', True)
@patch('seahub.api2.endpoints.send_upload_link_email.IS_EMAIL_CONFIGURED', True)
Expand All @@ -80,10 +80,10 @@ def test_can_send_email_rewrite_contact_email(self):

resp = self.client.post(url, data)
self.assertEqual(200, resp.status_code)
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(len(mail.outbox), 2)
json_resp = json.loads(resp.content)
assert json_resp['success'][0] == self.admin.email
assert mail.outbox[0].extra_headers['Reply-to'] == contact_email
assert mail.outbox[1].extra_headers['Reply-to'] == contact_email

@patch('seahub.utils.IS_EMAIL_CONFIGURED', False)
@patch('seahub.api2.endpoints.send_upload_link_email.IS_EMAIL_CONFIGURED', False)
Expand All @@ -98,7 +98,7 @@ def test_can_send_email_not_configured(self):

resp = self.client.post(url, data)
self.assertEqual(403, resp.status_code)
self.assertEqual(len(mail.outbox), 0)
self.assertEqual(len(mail.outbox), 1)

def test_can_not_send_email_if_not_link_owner(self):
self.login_as(self.admin)
Expand All @@ -110,4 +110,4 @@ def test_can_not_send_email_if_not_link_owner(self):

resp = self.client.post(url, data)
self.assertEqual(403, resp.status_code)
self.assertEqual(len(mail.outbox), 0)
self.assertEqual(len(mail.outbox), 1)

0 comments on commit b0c453f

Please sign in to comment.