-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to create email tag test cases
As #11 has a number of cases that we want to detect and possibly handle differently, test cases are needed. To create them reliably and without we use a script that creates sql commands. An alternative is have been to go through the fody-backend, but which would require one more component to run for building the test cases.
- Loading branch information
1 parent
fb27388
commit 33490a9
Showing
2 changed files
with
39 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
To be placed in `intelmq/tests/bots/`. | ||
`certbund_contact` is to be placed in `intelmq/tests/bots/`. |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
"""Create email tag example cases from a list of email addresses. | ||
The convention is that email addresses in the db have been changed | ||
by prepending an 'x-', so they differ from what the current ripe files have. | ||
We call them emailA. | ||
When run with ripe_diff the emails coming from the ripe files would be | ||
imported, thus new, we call them emailB. | ||
Precondition: At least we have tag_id 1 and 2 in the db. | ||
We skip safety checks and ignore style as this is for development. :) | ||
""" | ||
import fileinput | ||
|
||
def emailB(f): | ||
return f.readline().rstrip('\n') | ||
|
||
def emailA(f): | ||
return 'x-' + emailB(f) | ||
|
||
db_lines = [] | ||
|
||
with fileinput.input() as f: | ||
# case 1: both addresses have no tags, we do nothing | ||
f.readline() | ||
|
||
# case 2.1.1: emailA is disabled, emailB not | ||
db_lines.append("INSERT INTO email_status (email, enabled) VALUES ('{}','{}');".format(emailA(f), "false")) | ||
|
||
# case 2.1.2: emailA has a tag, emailB not | ||
db_lines.append("INSERT INTO email_tag (email, tag_id) VALUES ('{}','{}');".format(emailA(f), 1)) | ||
|
||
# TODO | ||
|
||
for db_line in db_lines: | ||
print(db_line) |