#NEWLINE# def _test_get_candidates( self , templates_id , slot_capacity = 5 , share_hosting_device = True , slot_need = 2 , expected_candidates = None ) : #NEWLINE# #INDENT# r_hd_b_db = mock . MagicMock ( ) #NEWLINE# r_hd_b_db . __getitem__ = ( lambda obj , name : fake_attrs [ name ] ) #NEWLINE# r_hd_b_db . share_hosting_device = share_hosting_device #NEWLINE# r_hd_b_db . router = mock . MagicMock ( ) #NEWLINE# fake_attrs = { #NEWLINE# #INDENT# 'template_id' : templates_id , #NEWLINE# 'tenant_id' : 'some_tenant' , #NEWLINE# #UNINDENT# } #NEWLINE# r_hd_b_db . router . __getitem__ = ( lambda obj , name : fake_attrs [ name ] ) #NEWLINE# r_hd_b_db . router_type = mock . MagicMock ( ) #NEWLINE# r_hd_b_db . router_type . slot_need = slot_need #NEWLINE# r_hd_b_db . router_type . __getitem__ = ( lambda obj , name : fake_attrs [ name ] ) #NEWLINE# r_hd_b_db . router_type . template = mock . MagicMock ( ) #NEWLINE# r_hd_b_db . router_type . template . slot_capacity = slot_capacity #NEWLINE# adm_ctx = n_context . get_admin_context ( ) #NEWLINE# sched_obj = scheduler . L3RouterHostingDeviceLongestRunningScheduler ( ) #NEWLINE# candidates = sched_obj . get_candidates ( None , adm_ctx , r_hd_b_db ) #NEWLINE# expected_candidates = ( expected_candidates or [ ] ) #NEWLINE# self . assertEqual ( len ( expected_candidates ) , len ( candidates ) ) #NEWLINE# for i in range ( len ( candidates ) ) : #NEWLINE# #INDENT# self . assertEqual ( expected_candidates [ i ] , candidates [ i ] [ 0 ] )