def publish_exists_event(self, context): """ Push this in Instance Tasks to fetch a report/collection :param context: currently None as specied in bin script """ mgmtmodels.publish_exist_events(self.exists_transformer, self.admin_context)
def test_public_exists_events(self): status = ServiceStatuses.BUILDING.api_status db_instance = DBInstance(InstanceTasks.BUILDING, created='xyz', name='test_name', id='1', flavor_id='flavor_1', compute_instance_id='compute_id_1', server_id='server_id_1', tenant_id='tenant_id_1', server_status=status) server = mock(Server) server.user_id = 'test_user_id' mgmt_instance = SimpleMgmtInstance(self.context, db_instance, server, None) when(mgmtmodels).load_mgmt_instances( self.context, deleted=False, client=self.client).thenReturn( [mgmt_instance, mgmt_instance]) flavor = mock(Flavor) flavor.name = 'db.small' when(self.flavor_mgr).get('flavor_1').thenReturn(flavor) when(notifier).notify(self.context, any(str), 'reddwarf.instance.exists', 'INFO', any(dict)).thenReturn(None) # invocation mgmtmodels.publish_exist_events( NovaNotificationTransformer(context=self.context), self.context) # assertion verify(notifier, times=2).notify(self.context, any(str), 'reddwarf.instance.exists', 'INFO', any(dict))