mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 06:41:43 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
11ae930c59 | |||
9c332c23d2 | |||
4ed0a49a44 |
@ -56,6 +56,7 @@ Group name must refer to architecture, e.g. it should be `email:x86_64` for x86_
|
||||
* `homepage` - link to homepage, string, optional.
|
||||
* `host` - SMTP host for sending emails, string, required.
|
||||
* `link_path` - prefix for HTML links, string, required.
|
||||
* `no_empty_report` - skip report generation for empty packages list, boolean, optional, default `yes`.
|
||||
* `password` - SMTP password to authenticate, string, optional.
|
||||
* `port` - SMTP port for sending emails, int, required.
|
||||
* `receivers` - SMTP receiver addresses, space separated list of strings, required.
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Maintainer: Evgeniy Alekseev
|
||||
|
||||
pkgname='ahriman'
|
||||
pkgver=0.22.0
|
||||
pkgver=0.22.1
|
||||
pkgrel=1
|
||||
pkgdesc="ArcHlinux ReposItory MANager"
|
||||
arch=('any')
|
||||
|
@ -26,6 +26,7 @@ target =
|
||||
target =
|
||||
|
||||
[email]
|
||||
no_empty_report = yes
|
||||
template_path = /usr/share/ahriman/repo-index.jinja2
|
||||
ssl = disabled
|
||||
|
||||
|
@ -36,6 +36,7 @@ class Email(Report, JinjaTemplate):
|
||||
"""
|
||||
email report generator
|
||||
:ivar host: SMTP host to connect
|
||||
:ivar no_empty_report: skip empty report generation
|
||||
:ivar password: password to authenticate via SMTP
|
||||
:ivar port: SMTP port to connect
|
||||
:ivar receivers: list of receivers emails
|
||||
@ -55,6 +56,7 @@ class Email(Report, JinjaTemplate):
|
||||
|
||||
# base smtp settings
|
||||
self.host = configuration.get("email", "host")
|
||||
self.no_empty_report = configuration.getboolean("email", "no_empty_report", fallback=True)
|
||||
self.password = configuration.get("email", "password", fallback=None)
|
||||
self.port = configuration.getint("email", "port")
|
||||
self.receivers = configuration.getlist("email", "receivers")
|
||||
@ -96,6 +98,8 @@ class Email(Report, JinjaTemplate):
|
||||
:param packages: list of packages to generate report
|
||||
:param built_packages: list of packages which has just been built
|
||||
"""
|
||||
if self.no_empty_report and not built_packages:
|
||||
return
|
||||
text = self.make_html(built_packages, False)
|
||||
attachments = {"index.html": self.make_html(packages, True)}
|
||||
self._send(text, attachments)
|
||||
|
@ -17,4 +17,4 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
__version__ = "0.22.0"
|
||||
__version__ = "0.22.1"
|
||||
|
@ -103,3 +103,28 @@ def test_generate_with_built(configuration: Configuration, package_ahriman: Pack
|
||||
report = Email("x86_64", configuration)
|
||||
report.generate([package_ahriman], [package_ahriman])
|
||||
send_mock.assert_called_once()
|
||||
|
||||
|
||||
def test_generate_no_empty(configuration: Configuration, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must not generate report with built packages if no_empty_report is set
|
||||
"""
|
||||
configuration.set("email", "no_empty_report", "yes")
|
||||
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
|
||||
|
||||
report = Email("x86_64", configuration)
|
||||
report.generate([package_ahriman], [])
|
||||
send_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_generate_no_empty_with_built(configuration: Configuration, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must generate report with built packages if no_empty_report is set
|
||||
"""
|
||||
configuration.set("email", "no_empty_report", "yes")
|
||||
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
|
||||
|
||||
report = Email("x86_64", configuration)
|
||||
report.generate([package_ahriman], [package_ahriman])
|
||||
send_mock.assert_called_once()
|
||||
|
@ -28,6 +28,7 @@ target =
|
||||
[email]
|
||||
host = 0.0.0.0
|
||||
link_path =
|
||||
no_empty_report = no
|
||||
port = 587
|
||||
receivers = mail@example.com
|
||||
sender = mail@example.com
|
||||
|
Reference in New Issue
Block a user