mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
- Add django-test-settings.py for Django settings - Add runtests.py for setting up Django test environment - Add Django test setup support to setup.py and coverage.py - Add new test module test_kvstore.py - Enable existing Django-dependent tests in test_context_processors.py and test_menu.py
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
#!/usr/bin/python3
|
|
#
|
|
# This file is part of Plinth.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
from django.test import TestCase
|
|
|
|
from plinth import kvstore
|
|
|
|
|
|
class KvstoreTestCase(TestCase):
|
|
"""Verify the behavior of the kvstore module."""
|
|
|
|
def test_get(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_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)
|