diff options
author | Dan Smith <dansmith@redhat.com> | 2016-02-11 11:48:13 -0800 |
---|---|---|
committer | Dan Smith <dansmith@redhat.com> | 2016-02-16 06:54:38 -0800 |
commit | b8296d82a0792900624efbaf040eff2cd488889b (patch) | |
tree | 41f8278260fd667bcff0e22e7e5cfc7c45bf2f0a /nova/tests/unit/test_fixtures.py | |
parent | 7ba2f294635683fe7db982f251a8238b2178f76b (diff) | |
download | nova-b8296d82a0792900624efbaf040eff2cd488889b.tar.gz |
Add StableObjectJsonFixture and use it in our base test class
This will ensure that our object JSON is stable during unit tests.
Specifically, the changes field, which is listified from a set, which
can vary in order.
Closes-Bug: #1545177
Change-Id: Ib40ca16c41d5422c18f4fc7d658273a8059100ab
Diffstat (limited to 'nova/tests/unit/test_fixtures.py')
-rw-r--r-- | nova/tests/unit/test_fixtures.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/nova/tests/unit/test_fixtures.py b/nova/tests/unit/test_fixtures.py index 16b87cea47..f0764fada5 100644 --- a/nova/tests/unit/test_fixtures.py +++ b/nova/tests/unit/test_fixtures.py @@ -331,3 +331,17 @@ class TestBannedDBSchemaOperations(testtools.TestCase): table.drop) self.assertRaises(exception.DBNotAllowed, table.alter) + + +class TestStableObjectJsonFixture(testtools.TestCase): + def test_changes_sort(self): + class TestObject(obj_base.NovaObject): + def obj_what_changed(self): + return ['z', 'a'] + + obj = TestObject() + self.assertEqual(['z', 'a'], + obj.obj_to_primitive()['nova_object.changes']) + with fixtures.StableObjectJsonFixture(): + self.assertEqual(['a', 'z'], + obj.obj_to_primitive()['nova_object.changes']) |