pagekite: 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:44 -07:00 committed by Joseph Nuthalapati
parent 0cacb21983
commit e53e120dbb
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35

View File

@ -19,40 +19,36 @@
Test modules for Pagekite functions. Test modules for Pagekite functions.
""" """
import unittest
from plinth.modules.pagekite import utils from plinth.modules.pagekite import utils
class TestPagekiteActions(unittest.TestCase): _tests = [
"""Test-cases for the pagekite action utils""" {
_tests = [ 'line': 'https/8080:*.@kitename:localhost:8080:@kitesecret',
{ 'params': {'kitename': '*.@kitename', 'backend_host': 'localhost',
'line': 'https/8080:*.@kitename:localhost:8080:@kitesecret', 'secret': '@kitesecret', 'protocol': 'https/8080',
'params': {'kitename': '*.@kitename', 'backend_host': 'localhost', 'backend_port': '8080'}
'secret': '@kitesecret', 'protocol': 'https/8080', },
'backend_port': '8080'} {
}, 'line': 'https:*.@kitename:localhost:80:@kitesecret',
{ 'params': {'protocol': 'https',
'line': 'https:*.@kitename:localhost:80:@kitesecret', 'kitename': '*.@kitename',
'params': {'protocol': 'https', 'backend_port': '80',
'kitename': '*.@kitename', 'backend_host': 'localhost',
'backend_port': '80', 'secret': '@kitesecret'}
'backend_host': 'localhost', },
'secret': '@kitesecret'} {
}, 'line': 'raw/22:@kitename:localhost:22:@kitesecret',
{ 'params': {'protocol': 'raw/22',
'line': 'raw/22:@kitename:localhost:22:@kitesecret', 'kitename': '@kitename',
'params': {'protocol': 'raw/22', 'backend_port': '22',
'kitename': '@kitename', 'backend_host': 'localhost',
'backend_port': '22', 'secret': '@kitesecret'}
'backend_host': 'localhost', },
'secret': '@kitesecret'} ]
},
]
def test_convert_service_to_string(self): def test_convert_service_to_string():
""" Test deconstructing parameter dictionaries into strings """ """ Test deconstructing parameter dictionaries into strings """
for test in self._tests: for test in _tests:
service_string = utils.convert_service_to_string(test['params']) service_string = utils.convert_service_to_string(test['params'])
self.assertEqual(test['line'], service_string) assert test['line'] == service_string