Exemplo n.º 1
0
    def test_obj_provided_without_to_dict_method(self):
        expected = {'foo': 'bar'}

        class FakeObj(object):
            def __init__(self):
                self.foo = expected['foo']

        fake_obj = FakeObj()
        result = nova._to_dict(fake_obj)
        self.assertEqual(expected, result)
Exemplo n.º 2
0
    def test_obj_provided_without_to_dict_method(self):
        expected = {'foo': 'bar'}

        class FakeObj(object):
            def __init__(self):
                self.foo = expected['foo']

        fake_obj = FakeObj()
        result = nova._to_dict(fake_obj)
        self.assertEqual(expected, result)
Exemplo n.º 3
0
    def test_obj_provided_with_to_dict_method(self):
        expected = {'foo': 'bar'}

        class FakeObj(object):
            def __init__(self):
                self.fake_attr = 'fake_attr_value'

            def to_dict(self):
                return expected

        fake_obj = FakeObj()
        result = nova._to_dict(fake_obj)
        self.assertEqual(expected, result)
Exemplo n.º 4
0
    def test_obj_provided_with_to_dict_method(self):
        expected = {'foo': 'bar'}

        class FakeObj(object):
            def __init__(self):
                self.fake_attr = 'fake_attr_value'

            def to_dict(self):
                return expected

        fake_obj = FakeObj()
        result = nova._to_dict(fake_obj)
        self.assertEqual(expected, result)
Exemplo n.º 5
0
 def test_dict_provided(self):
     fake_dict = {'foo_key': 'foo_value', 'bar_key': 'bar_value'}
     result = nova._to_dict(fake_dict)
     self.assertEqual(fake_dict, result)
Exemplo n.º 6
0
 def test_dict_provided(self):
     fake_dict = {'foo_key': 'foo_value', 'bar_key': 'bar_value'}
     result = nova._to_dict(fake_dict)
     self.assertEqual(fake_dict, result)
Exemplo n.º 7
0
 def test_dict_provided(self):
     fake_dict = {"foo_key": "foo_value", "bar_key": "bar_value"}
     result = nova._to_dict(fake_dict)
     self.assertEqual(fake_dict, result)