forked from canonical/snapd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release-tools: improve changelog help and inform of incorrect deb ema…
…il (canonical#13369) * release-tools: improved help and inform of incorrect deb email * fixed flake8 failure
- Loading branch information
Showing
2 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/usr/bin/python3 | ||
|
||
from io import StringIO | ||
import os | ||
import unittest | ||
|
||
import changelog | ||
|
@@ -35,5 +36,26 @@ def test_happy(self): | |
def test_version_not_found(self): | ||
with self.assertRaises(RuntimeError) as cm: | ||
changelog.read_changelogs_news_md(self.news_md, "1.1") | ||
print(dir(cm.exception)) | ||
self.assertEqual(str(cm.exception), 'cannot find expected version "1.1" in first header, found "New in snapd 2.60.3:"') | ||
|
||
def test_deb_email_happy(self): | ||
original = os.environ.get('DEBEMAIL') | ||
os.environ['DEBEMAIL'] = "FirstName LastName <[email protected]>" | ||
try: | ||
changelog.validate_env_deb_email() | ||
finally: | ||
if original: | ||
os.environ['DEBEMAIL'] = original | ||
|
||
def test_deb_email_errors(self): | ||
original = os.environ.get('DEBEMAIL') | ||
os.environ['DEBEMAIL'] = "" | ||
with self.assertRaises(RuntimeError) as e: | ||
changelog.validate_env_deb_email() | ||
self.assertEqual(str(e.exception), 'cannot find environment variable "DEBEMAIL", please provide DEBEMAIL="FirstName LastName <valid-email-address>"') | ||
os.environ['DEBEMAIL'] = "FirstName LastName <firstname.lastname.com>" | ||
with self.assertRaises(RuntimeError) as e: | ||
changelog.validate_env_deb_email() | ||
self.assertEqual(str(e.exception), 'environment variable "DEBEMAIL" uses incorrect format, expecting DEBEMAIL="FirstName LastName <valid-email-address>"') | ||
if original: | ||
os.environ['DEBEMAIL'] = original |