File: test_utils.py

package info (click to toggle)
drf-haystack 1.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 564 kB
  • sloc: python: 2,608; makefile: 147
file content (55 lines) | stat: -rw-r--r-- 1,504 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-

from __future__ import absolute_import, unicode_literals

from django.test import TestCase

from drf_haystack.utils import merge_dict


class MergeDictTestCase(TestCase):

    def setUp(self):
        self.dict_a = {
            "person": {
                "lastname": "Holmes",
                "combat_proficiency": [
                    "Pistol",
                    "boxing"
                ]
            },
        }
        self.dict_b = {
            "person": {
                "gender": "male",
                "firstname": "Sherlock",
                "location": {
                    "address": "221B Baker Street"
                },
                "combat_proficiency": [
                    "sword",
                    "Martial arts",
                ]
            }
        }

    def test_utils_merge_dict(self):
        self.assertEqual(merge_dict(self.dict_a, self.dict_b), {
            "person": {
                "gender": "male",
                "firstname": "Sherlock",
                "lastname": "Holmes",
                "location": {
                    "address": "221B Baker Street"
                },
                "combat_proficiency": [
                    "Martial arts",
                    "Pistol",
                    "boxing",
                    "sword",
                ]
            }
        })

    def test_utils_merge_dict_invalid_input(self):
        self.assertEqual(merge_dict(self.dict_a, "I'm not a dict!"), "I'm not a dict!")