nova/nova/tests
Shane Wang 39870b603d Fix misspellings in nova
Fix misspellings detected by:
* pip install misspellings
* git ls-files | grep -v locale | misspellings -f -

Change-Id: I4e60889368b5e83275d59562613623c417a8e03f
Closes-Bug: #1257295
2014-02-07 13:09:24 +08:00
..
CA
api Fix misspellings in nova 2014-02-07 13:09:24 +08:00
bundle
cells Remove vi modelines 2014-02-03 14:19:44 +00:00
cert Remove vi modelines 2014-02-03 14:19:44 +00:00
compute Fix misspellings in nova 2014-02-07 13:09:24 +08:00
conductor Remove vi modelines 2014-02-03 14:19:44 +00:00
console Remove vi modelines 2014-02-03 14:19:44 +00:00
consoleauth Remove vi modelines 2014-02-03 14:19:44 +00:00
db Fix misspellings in nova 2014-02-07 13:09:24 +08:00
fake_loadables
glance Remove vi modelines 2014-02-03 14:19:44 +00:00
image Remove vi modelines 2014-02-03 14:19:44 +00:00
integrated Remove vi modelines 2014-02-03 14:19:44 +00:00
keymgr Remove vi modelines 2014-02-03 14:19:44 +00:00
monkey_patch_example Remove vi modelines 2014-02-03 14:19:44 +00:00
network Merge "Make nova-network use FixedIP object for associations" 2014-02-06 17:21:15 +00:00
objects Add instance_get_active_by_window_joined to InstanceList 2014-02-03 19:14:33 -08:00
pci Remove vi modelines 2014-02-03 14:19:44 +00:00
scheduler Fix misspellings in nova 2014-02-07 13:09:24 +08:00
servicegroup Make sure report_interval is less than service_down_time 2013-11-27 13:06:15 +08:00
ssl_cert
virt Merge "Fix bittorrent URL configuration option" 2014-02-06 18:42:57 +00:00
volume Remove vi modelines 2014-02-03 14:19:44 +00:00
README.rst Mox should cleanup before stubs 2013-05-16 18:15:31 +00:00
__init__.py Remove vi modelines 2014-02-03 14:19:44 +00:00
cast_as_call.py Remove vi modelines 2014-02-03 14:19:44 +00:00
conf_fixture.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_block_device.py Add block device mapping objects implementation 2014-01-30 15:28:05 +01:00
fake_crypto.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_hosts.py Make compute_api use Service and ComputeNode objects 2013-08-29 00:18:46 -07:00
fake_instance.py Update Instance from database after destroy 2013-12-04 13:01:46 -05:00
fake_instance_actions.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_ldap.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_network.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_network_cache_model.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_notifier.py Add serializer capability to fake_notifier. 2014-02-04 13:45:29 -06:00
fake_policy.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_processutils.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fake_utils.py Call scheduler for run_instance from conductor 2013-06-04 13:42:04 -04:00
fake_volume.py Remove vi modelines 2014-02-03 14:19:44 +00:00
fakeguestfs.py Remove vi modelines 2014-02-03 14:19:44 +00:00
matchers.py Remove vi modelines 2014-02-03 14:19:44 +00:00
policy_fixture.py
test_api_validation.py Define common "name" parameter for Nova v3 API 2014-02-05 19:43:07 +09:00
test_availability_zones.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_baserpc.py Move get_backdoor_port to base rpc API. 2013-04-24 15:02:56 -04:00
test_bdm.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_block_device.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_cinder.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_configdrive2.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_context.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_crypto.py Convert to using oslo's execute() method. 2013-05-04 15:17:40 +10:00
test_exception.py Fix misspellings in nova 2014-02-07 13:09:24 +08:00
test_flavors.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_hacking.py Add hacking test to block cross-virt driver code usage 2014-02-04 18:01:11 +00:00
test_hooks.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_instance_types_extra_specs.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_iptables_network.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_ipv6.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_linuxscsi.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_loadables.py Convert TestCases to NoDBTestCase 2013-09-19 19:53:04 +10:00
test_matchers.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_metadata.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_notifications.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_nova_manage.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_objectstore.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_pipelib.py
test_policy.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_quota.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_safeutils.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_service.py Merge "Make sure report_interval is less than service_down_time" 2014-02-06 12:59:44 +00:00
test_test.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_test_utils.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_utils.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_versions.py Remove vi modelines 2014-02-03 14:19:44 +00:00
test_weights.py Normalize the weights instead of using raw values 2013-12-11 20:24:16 +01:00
test_wsgi.py Remove vi modelines 2014-02-03 14:19:44 +00:00
utils.py Remove vi modelines 2014-02-03 14:19:44 +00:00

README.rst

OpenStack Nova Testing Infrastructure

This README file attempts to provide current and prospective contributors with everything they need to know in order to start creating unit tests for nova.

Note: the content for the rest of this file will be added as the work items in the following blueprint are completed: https://blueprints.launchpad.net/nova/+spec/consolidate-testing-infrastructure

Test Types: Unit vs. Functional vs. Integration

TBD

Writing Unit Tests

TBD

Using Fakes

TBD

test.TestCase

The TestCase class from nova.test (generally imported as test) will automatically manage self.stubs using the stubout module and self.mox using the mox module during the setUp step. They will automatically verify and clean up during the tearDown step.

If using test.TestCase, calling the super class setUp is required and calling the super class tearDown is required to be last if tearDown is overriden.

Writing Functional Tests

TBD

Writing Integration Tests

TBD

Tests and Exceptions

A properly written test asserts that particular behavior occurs. This can be a success condition or a failure condition, including an exception. When asserting that a particular exception is raised, the most specific exception possible should be used.

In particular, testing for Exception being raised is almost always a mistake since it will match (almost) every exception, even those unrelated to the exception intended to be tested.

This applies to catching exceptions manually with a try/except block, or using assertRaises().

Example:

self.assertRaises(exception.InstanceNotFound, db.instance_get_by_uuid,
                  elevated, instance_uuid)

If a stubbed function/method needs a generic exception for testing purposes, test.TestingException is available.

Example:

def stubbed_method(self):
    raise test.TestingException()
self.stubs.Set(cls, 'inner_method', stubbed_method)

obj = cls()
self.assertRaises(test.TestingException, obj.outer_method)

Stubbing and Mocking

Whenever possible, tests SHOULD NOT stub and mock out the same function.

If it's unavoidable, tests SHOULD define stubs before mocks since the TestCase cleanup routine will un-mock before un-stubbing. Doing otherwise results in a test that leaks stubbed functions, causing hard-to-debug interference between tests1.

If a mock must take place before a stub, any stubs after the mock call MUST be manually unset using self.cleanUp calls within the test.


  1. https://bugs.launchpad.net/nova/+bug/1180671↩︎