mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
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:
parent
8587df1f4a
commit
0fb7cb9331
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user