Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compendium-v2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
compendium-v2
Commits
d9668de2
Commit
d9668de2
authored
1 year ago
by
geant-release-service
Browse files
Options
Downloads
Plain Diff
Finished release 0.34.
parents
96bcf4e2
7baef30a
Branches
Branches containing commit
Tags
0.34
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Changelog.md
+3
-0
3 additions, 0 deletions
Changelog.md
compendium_v2/email/__init__.py
+2
-0
2 additions, 0 deletions
compendium_v2/email/__init__.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
test/test_send_mail.py
+20
-1
20 additions, 1 deletion
test/test_send_mail.py
with
26 additions
and
2 deletions
Changelog.md
+
3
−
0
View file @
d9668de2
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
All notable changes to this project will be documented in this file.
## [0.34] - 2023-08-27
-
Fixed bug with "To" address for single email recipient
## [0.33] - 2023-08-27
## [0.33] - 2023-08-27
-
Fixed utf-8 issues with sending emails
-
Fixed utf-8 issues with sending emails
-
Fixed bug with applying migrations disabling all logging
-
Fixed bug with applying migrations disabling all logging
...
...
This diff is collapsed.
Click to expand it.
compendium_v2/email/__init__.py
+
2
−
0
View file @
d9668de2
...
@@ -54,6 +54,8 @@ def send_mail(
...
@@ -54,6 +54,8 @@ def send_mail(
if
not
recipients
:
if
not
recipients
:
recipients
=
admin_emails
recipients
=
admin_emails
if
isinstance
(
recipients
,
str
):
recipients
=
[
recipients
]
message
=
MIMEMultipart
(
'
alternative
'
)
message
=
MIMEMultipart
(
'
alternative
'
)
message
[
'
Subject
'
]
=
subject
message
[
'
Subject
'
]
=
subject
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
d9668de2
...
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
...
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup
(
setup
(
name
=
'
compendium-v2
'
,
name
=
'
compendium-v2
'
,
version
=
"
0.3
3
"
,
version
=
"
0.3
4
"
,
author
=
'
GEANT
'
,
author
=
'
GEANT
'
,
author_email
=
'
swd@geant.org
'
,
author_email
=
'
swd@geant.org
'
,
description
=
'
Flask and React project for displaying
'
description
=
'
Flask and React project for displaying
'
...
...
This diff is collapsed.
Click to expand it.
test/test_send_mail.py
+
20
−
1
View file @
d9668de2
from
typing
import
List
from
typing
import
List
from
email.mime.multipart
import
MIMEMultipart
from
email.mime.multipart
import
MIMEMultipart
from
email.mime.text
import
MIMEText
# noqa: F401
from
email.mime.text
import
MIMEText
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
compendium_v2.db.auth_model
import
User
from
compendium_v2.db.auth_model
import
User
from
compendium_v2.email
import
send_admin_signup_notification
,
send_user_signup_notification
from
compendium_v2.email
import
send_admin_signup_notification
,
send_user_signup_notification
class
MockedThread
(
object
):
def
__init__
(
self
,
target
,
args
):
self
.
target
=
target
self
.
args
=
args
def
start
(
self
):
self
.
target
(
*
self
.
args
)
def
decode_message
(
msg
:
MIMEMultipart
):
def
decode_message
(
msg
:
MIMEMultipart
):
message
:
List
[
MIMEText
]
=
msg
.
get_payload
()
message
:
List
[
MIMEText
]
=
msg
.
get_payload
()
text
:
MIMEText
=
message
[
0
]
text
:
MIMEText
=
message
[
0
]
...
@@ -30,10 +39,15 @@ def test_signup_email_admin(app, mocked_admin_user, mocker):
...
@@ -30,10 +39,15 @@ def test_signup_email_admin(app, mocked_admin_user, mocker):
def
_send_mail
(
*
args
,
**
kwargs
):
def
_send_mail
(
*
args
,
**
kwargs
):
_msg
=
args
[
-
1
]
_msg
=
args
[
-
1
]
decoded
=
decode_message
(
_msg
)
decoded
=
decode_message
(
_msg
)
_from
=
_msg
[
'
From
'
]
_to
=
_msg
[
'
To
'
]
assert
_from
==
'
fakesender123@test.local
'
assert
_to
==
'
testemail123@email.local
'
message
=
'
testname has just signed up with the email testmail321@email.com and provider ID testsub
'
message
=
'
testname has just signed up with the email testmail321@email.com and provider ID testsub
'
assert
decoded
==
message
assert
decoded
==
message
mocker
.
patch
(
'
compendium_v2.email._send_mail
'
,
_send_mail
)
mocker
.
patch
(
'
compendium_v2.email._send_mail
'
,
_send_mail
)
mocker
.
patch
(
'
threading.Thread
'
,
MockedThread
)
with
test_user
(
app
)
as
user
:
with
test_user
(
app
)
as
user
:
send_admin_signup_notification
(
user
)
send_admin_signup_notification
(
user
)
...
@@ -42,9 +56,14 @@ def test_signup_email_user(app, mocker):
...
@@ -42,9 +56,14 @@ def test_signup_email_user(app, mocker):
def
_send_mail
(
*
args
,
**
kwargs
):
def
_send_mail
(
*
args
,
**
kwargs
):
_msg
=
args
[
-
1
]
_msg
=
args
[
-
1
]
_from
=
_msg
[
'
From
'
]
_to
=
_msg
[
'
To
'
]
assert
_from
==
'
fakesender123@test.local
'
assert
_to
==
'
testmail321@email.com
'
decoded
=
decode_message
(
_msg
)
decoded
=
decode_message
(
_msg
)
assert
len
(
decoded
)
>
50
# check that there's a message
assert
len
(
decoded
)
>
50
# check that there's a message
mocker
.
patch
(
'
compendium_v2.email._send_mail
'
,
_send_mail
)
mocker
.
patch
(
'
compendium_v2.email._send_mail
'
,
_send_mail
)
mocker
.
patch
(
'
threading.Thread
'
,
MockedThread
)
with
test_user
(
app
)
as
user
:
with
test_user
(
app
)
as
user
:
send_user_signup_notification
(
user
,
'
testname
'
)
send_user_signup_notification
(
user
,
'
testname
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment