letsencrypt: Convert tests to pytest style

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
Sunil Mohan Adapa 2019-05-01 16:08:18 -07:00 committed by Joseph Nuthalapati
parent a195fdca57
commit 54b684dbaf
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35

View File

@ -18,30 +18,21 @@
Tests for letsencrypt module.
"""
import os
import os.path
import unittest
import pytest
from .. import on_domain_added, on_domain_removed
euid = os.geteuid()
sudo_available = os.path.isfile("/usr/bin/sudo")
pytestmark = pytest.mark.usefixtures('needs_root', 'needs_sudo')
@unittest.skipUnless(sudo_available, 'Requires sudo')
class TestDomainNameChanges(unittest.TestCase):
"""Test for automatically obtaining and revoking Let's Encrypt certs"""
def test_add_onion_domain():
assert not on_domain_added('test', 'hiddenservice', 'ddddd.onion')
@unittest.skipUnless(euid == 0, 'Needs to be root')
def test_add_onion_domain(self):
self.assertFalse(
on_domain_added('test', 'hiddenservice', 'ddddd.onion'))
@unittest.skipUnless(euid == 0, 'Needs to be root')
def test_add_valid_domain(self):
self.assertTrue(
on_domain_added('test', 'domainname', 'subdomain.domain.tld'))
@pytest.mark.usefixtures('load_cfg')
def test_add_valid_domain():
assert on_domain_added('test', 'domainname', 'subdomain.domain.tld')
@unittest.skipUnless(euid == 0, 'Needs to be root')
def test_remove_domain(self):
self.assertTrue(on_domain_removed('test', '', 'somedomain.tld'))
def test_remove_domain():
assert on_domain_removed('test', '', 'somedomain.tld')