Debian Codegraph @

tests/test_utils.py

raw
1 # -*- coding: utf-8 -*-
2
3 from __future__ import absolute_import, unicode_literals
4
5 from django.test import TestCase
6
7 from drf_haystack.utils import merge_dict
8
9
10 class MergeDictTestCase(TestCase):
11
12 def setUp(self):
13 self.dict_a = {
14 "person": {
15 "lastname": "Holmes",
16 "combat_proficiency": [
17 "Pistol",
18 "boxing"
19 ]
20 },
21 }
22 self.dict_b = {
23 "person": {
24 "gender": "male",
25 "firstname": "Sherlock",
26 "location": {
27 "address": "221B Baker Street"
28 },
29 "combat_proficiency": [
30 "sword",
31 "Martial arts",
32 ]
33 }
34 }
35
36 def test_utils_merge_dict(self):
37 self.assertEqual(merge_dict(self.dict_a, self.dict_b), {
38 "person": {
39 "gender": "male",
40 "firstname": "Sherlock",
41 "lastname": "Holmes",
42 "location": {
43 "address": "221B Baker Street"
44 },
45 "combat_proficiency": [
46 "Martial arts",
47 "Pistol",
48 "boxing",
49 "sword",
50 ]
51 }
52 })
53
54 def test_utils_merge_dict_invalid_input(self):
55 self.assertEqual(merge_dict(self.dict_a, "I'm not a dict!"), "I'm not a dict!")