-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from FRosner/issue/123
EmailReporter (Issue/123)
- Loading branch information
Showing
12 changed files
with
1,135 additions
and
11 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
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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
from pyspark.sql import SQLContext | ||
|
||
from pyddq.core import Check | ||
from pyddq.reporters import ConsoleReporter, MarkdownReporter, ZeppelinReporter | ||
from pyddq.reporters import ConsoleReporter, MarkdownReporter, ZeppelinReporter, EmailReporter | ||
from pyddq.streams import ByteArrayOutputStream | ||
|
||
|
||
|
@@ -89,6 +89,43 @@ def test_output(self): | |
""".strip() | ||
self.assertEqual(baos.get_output(), expected_output) | ||
|
||
class EmailReporterTest(unittest.TestCase): | ||
def setUp(self): | ||
self.sc = SparkContext() | ||
self.sql = SQLContext(self.sc) | ||
self.df = self.sql.createDataFrame([(1, "a"), (1, None), (3, "c")]) | ||
|
||
def tearDown(self): | ||
self.sc.stop() | ||
|
||
def test_default_arguments(self): | ||
check = Check(self.df).hasUniqueKey("_1").hasUniqueKey("_1", "_2") | ||
reporter = EmailReporter("[email protected]", {"[email protected]"}) | ||
check.run([reporter]) | ||
|
||
def test_passed_arguments(self): | ||
check = Check(self.df).hasUniqueKey("_1").hasUniqueKey("_1", "_2") | ||
smtpServer = "[email protected]" | ||
to = {"[email protected]"} | ||
cc = {"[email protected]"} | ||
subjectPrefix = "my subject prefix: " | ||
smtpPort = 9000 | ||
from_ = "test.ddq.io" | ||
usernameAndPassword = ("username", "password") | ||
reportOnlyOnFailure = True | ||
accumulatedReport = True | ||
reporter = EmailReporter( | ||
smtpServer, to, cc, subjectPrefix, smtpPort, from_, | ||
usernameAndPassword, reportOnlyOnFailure, accumulatedReport | ||
) | ||
check.run([reporter]) | ||
|
||
def test_accumulated_report(self): | ||
check = Check(self.df).hasUniqueKey("_1").hasUniqueKey("_1", "_2") | ||
reporter = EmailReporter("[email protected]", {"[email protected]"}, accumulatedReport=True) | ||
check.run([reporter]) | ||
reporter.sendAccumulatedReport() | ||
reporter.sendAccumulatedReport("111") | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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
Oops, something went wrong.