kvstore: 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:11:21 -07:00 committed by Joseph Nuthalapati
parent 8587df1f4a
commit 0fb7cb9331
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35

View File

@ -21,34 +21,32 @@ Test module for key/value store.
import pytest
from django.test import TestCase
from plinth import kvstore
pytestmark = pytest.mark.django_db
@pytest.mark.django_db
class KVStoreTestCase(TestCase):
"""Verify the behavior of the kvstore module."""
def test_get_set(self):
"""Verify that a set value can be retrieved."""
key = 'name'
expected_value = 'Guido'
kvstore.set(key, expected_value)
actual_value = kvstore.get(key)
self.assertEqual(expected_value, actual_value)
def test_get_set():
"""Verify that a set value can be retrieved."""
key = 'name'
expected_value = 'Guido'
kvstore.set(key, expected_value)
actual_value = kvstore.get(key)
assert expected_value == actual_value
def test_get_set_complex_structures(self):
"""Verify that complex structures can be stored and retrieved."""
key = 'compex_structure'
expected_value = {'k1': 1, 'k2': [2, 3], 'k3': 4.5, 'k4': 'Hello',
'k5': {'a': 'b'}}
kvstore.set(key, expected_value)
actual_value = kvstore.get(key)
self.assertEqual(expected_value, actual_value)
def test_get_default(self):
"""Verify that either a set value or its default can be retrieved."""
expected = 'default'
actual = kvstore.get_default('bad_key', expected)
self.assertEqual(expected, actual)
def test_get_set_complex_structures():
"""Verify that complex structures can be stored and retrieved."""
key = 'compex_structure'
expected_value = {'k1': 1, 'k2': [2, 3], 'k3': 4.5, 'k4': 'Hello',
'k5': {'a': 'b'}}
kvstore.set(key, expected_value)
actual_value = kvstore.get(key)
assert expected_value == actual_value
def test_get_default():
"""Verify that either a set value or its default can be retrieved."""
expected = 'default'
actual = kvstore.get_default('bad_key', expected)
assert expected == actual