summaryrefslogtreecommitdiff
path: root/ishtar_common/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r--ishtar_common/tests.py63
1 files changed, 62 insertions, 1 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 90a9d10ad..65a5a7593 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -45,7 +45,7 @@ from django.test.runner import DiscoverRunner
from ishtar_common import models
from ishtar_common import views
from ishtar_common.apps import admin_site
-from ishtar_common.utils import post_save_point
+from ishtar_common.utils import post_save_point, update_data, move_dict_data
COMMON_FIXTURES = [
@@ -93,6 +93,67 @@ class TestCase(BaseTestCase):
pass
+class UtilsTest(TestCase):
+ def test_update_data(self):
+ data_1 = {
+ 'old':
+ {'youpi':
+ {'plouf': u'tralalalère'}}
+ }
+ data_2 = {
+ 'tsoin_tsoin': 'hop',
+ 'old':
+ {'hoppy': 'hop'}
+ }
+ expected = {
+ 'tsoin_tsoin': 'hop',
+ 'old':
+ {'youpi':
+ {'plouf': u'tralalalère'},
+ 'hoppy': 'hop'}
+ }
+ res = update_data(data_1, data_2)
+ self.assertEqual(res, expected)
+
+ def test_move_dict_data(self):
+ data = {
+ 'old': {u'daté': "value"}
+ }
+ expected = {
+ 'old': {'date': "value"}
+ }
+ res = move_dict_data(
+ data, u'data__old__daté', u"data__old__date")
+ self.assertEqual(res, expected)
+ data = {
+ '': {'hop': "value"}
+ }
+ expected = {
+ 'hop': "value",
+ '': {}
+ }
+ res = move_dict_data(data, u'data____hop', u"data__hop")
+ self.assertEqual(res, expected)
+ data = {
+ 'old': {
+ 'traitement': {
+ u'constat_état': 'aaa'
+ }
+ }
+ }
+ expected = {
+ 'old': {
+ 'traitement': {
+ 'constat_etat': 'aaa'
+ }
+ }
+ }
+ res = move_dict_data(data,
+ u'data__old__traitement__constat_état',
+ u'data__old__traitement__constat_etat')
+ self.assertEqual(res, expected)
+
+
class CommandsTestCase(TestCase):
fixtures = [settings.ROOT_PATH +
'../ishtar_common/fixtures/test_towns.json']