blob: 2656a4736d98e50b3bc4232af961ec1458ad3f1b [file] [log] [blame]
Andrea Frittolib6e1a282014-08-05 20:08:27 +01001# Copyright 2014 Hewlett-Packard Development Company, L.P.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.common import custom_matchers
Matthew Treinishffad78a2016-04-16 14:39:52 -040017from tempest.tests import base
Andrea Frittolib6e1a282014-08-05 20:08:27 +010018
19from testtools.tests.matchers import helpers
20
21
22class TestMatchesDictExceptForKeys(base.TestCase,
23 helpers.TestMatchersInterface):
24
25 matches_matcher = custom_matchers.MatchesDictExceptForKeys(
26 {'a': 1, 'b': 2, 'c': 3, 'd': 4}, ['c', 'd'])
27 matches_matches = [
28 {'a': 1, 'b': 2, 'c': 3, 'd': 4},
29 {'a': 1, 'b': 2, 'c': 5},
30 {'a': 1, 'b': 2},
31 ]
32 matches_mismatches = [
33 {},
34 {'foo': 1},
35 {'a': 1, 'b': 3},
36 {'a': 1, 'b': 2, 'foo': 1},
37 {'a': 1, 'b': None, 'foo': 1},
38 ]
39
40 str_examples = []
41 describe_examples = [
42 ("Only in expected:\n"
43 " {'a': 1, 'b': 2}\n",
44 {},
45 matches_matcher),
46 ("Only in expected:\n"
47 " {'a': 1, 'b': 2}\n"
48 "Only in actual:\n"
49 " {'foo': 1}\n",
50 {'foo': 1},
51 matches_matcher),
52 ("Differences:\n"
53 " b: expected 2, actual 3\n",
54 {'a': 1, 'b': 3},
55 matches_matcher),
56 ("Only in actual:\n"
57 " {'foo': 1}\n",
58 {'a': 1, 'b': 2, 'foo': 1},
59 matches_matcher),
60 ("Only in actual:\n"
61 " {'foo': 1}\n"
62 "Differences:\n"
63 " b: expected 2, actual None\n",
64 {'a': 1, 'b': None, 'foo': 1},
65 matches_matcher)
Joe Gordon28788b42015-02-25 12:42:37 -080066 ]