Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4792534
test_edit_acme_dns_accounts.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
test_edit_acme_dns_accounts.py
View Options
#!/usr/bin/env python3
from
importlib.machinery
import
SourceFileLoader
import
os
import
unittest
os
.
environ
[
"ACME_ACCOUNTS"
]
=
"/path/to/acmedns.json"
path
=
"roles/paas-docker/letsencrypt/files/edit-acme-dns-accounts.py"
script
=
SourceFileLoader
(
"script"
,
"../"
+
path
)
.
load_module
()
class
TestInstance
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
testAccounts
=
script
.
AcmeAccounts
(
"/dev/null"
)
pass
def
test_read_path_from_environment
(
self
):
self
.
assertEqual
(
"/path/to/acmedns.json"
,
script
.
get_acme_accounts_path
())
def
test_accounts_are_empty_on_init
(
self
):
self
.
assertEqual
({},
self
.
testAccounts
.
accounts
)
def
test_add
(
self
):
self
.
testAccounts
.
add
(
"foo.tld"
,
{})
self
.
assertEqual
(
1
,
len
(
self
.
testAccounts
.
accounts
))
self
.
assertIn
(
"foo.tld"
,
self
.
testAccounts
.
accounts
)
def
test_remove_existing
(
self
):
self
.
testAccounts
.
add
(
"foo.tld"
,
{})
self
.
assertTrue
(
self
.
testAccounts
.
remove
(
"foo.tld"
))
self
.
assertEqual
(
0
,
len
(
self
.
testAccounts
.
accounts
))
def
test_remove_non_existing
(
self
):
self
.
assertFalse
(
self
.
testAccounts
.
remove
(
"not-existing.tld"
))
def
test_merge
(
self
):
accounts_to_merge
=
script
.
AcmeAccounts
(
"/dev/null"
)
.
add
(
"bar.tld"
,
{})
self
.
testAccounts
.
add
(
"foo.tld"
,
{})
.
merge_with
(
accounts_to_merge
)
self
.
assertEqual
(
2
,
len
(
self
.
testAccounts
.
accounts
))
if
__name__
==
"__main__"
:
unittest
.
main
()
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Fri, Feb 28, 20:13 (4 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2436066
Default Alt Text
test_edit_acme_dns_accounts.py (1 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment