def testGetVersions_CurrentModule(self): self.request_data.get_dispatcher().AndReturn(self.dispatcher) self.request_data.get_module(None).AndReturn('default') self.dispatcher.get_versions('default').AndReturn(['1', '2']) self.mox.ReplayAll() self.assertEqual(['1', '2'], modules.get_versions()) self.mox.VerifyAll()
def cron_stop_non_default_instances(): # core logic (inside a cron or other handler) for m in modules.get_modules(): dv = modules.get_default_version(m) for v in modules.get_versions(m): if v != dv: modules.stop_version(m, v) return "Success!"
def testGetVersions_NoModule(self): """Test we return the expected results when no module is passed.""" expected_request = modules_service_pb2.GetVersionsRequest() service_response = modules_service_pb2.GetVersionsResponse() service_response.version.append('v1') service_response.version.append('v2') self.SetSuccessExpectations('GetVersions', expected_request, service_response) self.assertEqual(['v1', 'v2'], modules.get_versions())