~blake-rouse/maas/maas-automate

« back to all changes in this revision

Viewing changes to src/maasserver/tests/test_bootresources.py

  • Committer: Gavin Panella
  • Date: 2015-09-23 10:36:16 UTC
  • mto: This revision was merged to the branch mainline in revision 4295.
  • Revision ID: gavin.panella@canonical.com-20150923103616-poc149m65in4uptf
Ensure that _import_resources() is never called within a transaction, test it, and document it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
)
62
62
from maasserver.rpc.testing.fixtures import MockLiveRegionToClusterRPCFixture
63
63
from maasserver.testing.config import RegionConfigurationFixture
 
64
from maasserver.testing.dblocks import lock_held_in_other_thread
64
65
from maasserver.testing.eventloop import (
65
66
    RegionEventLoopFixture,
66
67
    RunningEventLoopFixture,
1144
1145
    def test__import_resources_exits_early_if_lock_held(self):
1145
1146
        has_synced_resources = self.patch_autospec(
1146
1147
            bootresources, "has_synced_resources")
1147
 
        with transaction.atomic():
1148
 
            with bootresources.locks.import_images:
1149
 
                bootresources._import_resources(force=True)
 
1148
        with lock_held_in_other_thread(bootresources.locks.import_images):
 
1149
            bootresources._import_resources(force=True)
1150
1150
        # The test for already-synced resources is not called if the
1151
1151
        # lock is already held.
1152
1152
        self.assertThat(has_synced_resources, MockNotCalled())