# Copyright (c) 2013 Hortonworks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import collections

import testtools

from sahara.utils import hashabledict as h


class HashableDictTest(testtools.TestCase):

    def test_is_hashable(self):
        hd = h.HashableDict()
        hd['one'] = 'oneValue'

        self.assertTrue(isinstance(hd, collections.Hashable))

# Copyright (c) 2013 Hortonworks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import collections

import testtools

from sahara.utils import hashabledict as h


class HashableDictTest(testtools.TestCase):

    def test_is_hashable_collection(self):
        dct = h.HashableDict(one='oneValue')
        self.assertIsInstance(dct, collections.Hashable)

    def test_hash_consistency(self):
        dct1 = h.HashableDict(one='oneValue')
        dct2 = h.HashableDict(one='oneValue')
        self.assertEqual(hash(dct1), hash(dct2))

Improve unit test for HashableDict
Improve unit test for HashableDict

We have HashableDict introduced to network info storing, but hash
function of this implementation was never tested in unit tests.

Change-Id: Id48c9172ca63e19b397dc131d85ed631874142cd
