Base classes for our unit tests.
Allows overriding of flags for use of fakes, and some black magic for inline callbacks.
Bases: nova.test.NoDBTestCase
Bases: object
Matches any instance of a specified type
The MatchType class is a helper for use with the mock.assert_called_with() method that lets you assert that a particular parameter has a specific data type. It enables strict check than the built in mock.ANY helper, and is the equivalent of the mox.IsA() function from the legacy mox library
Example usage could be:
- mock_some_method.assert_called_once_with(
- “hello”, MatchType(objects.Instance), mock.ANY, “world”, MatchType(objects.KeyPair))
Bases: nova.test.TestCase
NoDBTestCase differs from TestCase in that DB access is not supported. This makes tests run significantly faster. If possible, all new tests should derive from this class.
Bases: fixtures.fixture.Fixture
Create sample networks in the database.
Bases: testtools.testcase.TestCase
Test case base class for all unit tests.
Due to the slowness of DB access, please consider deriving from NoDBTestCase first.
Asserts that 2 complex data structures are json equivalent.
We use data structures which serialize down to json throughout the code, and often times we just need to know that these are json equivalent. This means that list order is not important, and should be sorted.
Because this is a recursive set of assertions, when failure happens we want to expose both the local failure and the global view of the 2 data structures being compared. So a MismatchError which includes the inner failure as the mismatch, and the passed in expected / observed as matchee / matcher.
Override flag variables for a test.
Run before each test method to initialize test environment.
Replace a function for the duration of the test.
Use the monkey patch fixture to replace a function for the duration of a test. Useful when you want to provide fake methods instead of mocks during testing.
This should be used instead of self.stubs.Set (which is based on mox) going forward.
Bases: exceptions.Exception
Bases: fixtures.fixture.Fixture
Fixture to start and remove time override.
Bases: object