<s> import datetime <EOL> from nova import objects <EOL> from nova . scheduler . filters import metrics_filter <EOL> from nova import test <EOL> from nova . tests . unit . scheduler import fakes <EOL> class TestMetricsFilter ( test . NoDBTestCase ) : <EOL> def test_metrics_filter_pass ( self ) : <EOL> _ts_now = datetime . datetime ( <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT:11> , <NUM_LIT:11> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> obj1 = objects . MonitorMetric ( name = '<STR_LIT>' , <EOL> value = <NUM_LIT:1000> , <EOL> timestamp = _ts_now , <EOL> source = '<STR_LIT>' ) <EOL> obj2 = objects . MonitorMetric ( name = '<STR_LIT>' , <EOL> numa_membw_values = { "<STR_LIT:0>" : <NUM_LIT:10> , "<STR_LIT:1>" : <NUM_LIT> } , <EOL> timestamp = _ts_now , <EOL> source = '<STR_LIT>' ) <EOL> metrics_list = objects . MonitorMetricList ( objects = [ obj1 , obj2 ] ) <EOL> self . flags ( weight_setting = [ <EOL> '<STR_LIT>' , '<STR_LIT>' ] , group = '<STR_LIT>' ) <EOL> filt_cls = metrics_filter . MetricsFilter ( ) <EOL> host = fakes . FakeHostState ( '<STR_LIT>' , '<STR_LIT>' , <EOL> attribute_dict = { '<STR_LIT>' : metrics_list } ) <EOL> self . assertTrue ( filt_cls . host_passes ( host , None ) ) <EOL> def test_metrics_filter_missing_metrics ( self ) : <EOL> _ts_now = datetime . datetime ( <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT:11> , <NUM_LIT:11> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> obj1 = objects . MonitorMetric ( name = '<STR_LIT>' , <EOL> value = <NUM_LIT:1000> , <EOL> timestamp = _ts_now , <EOL> source = '<STR_LIT>' ) <EOL> metrics_list = objects . MonitorMetricList ( objects = [ obj1 ] ) <EOL> self . flags ( weight_setting = [ '<STR_LIT>' , '<STR_LIT>' ] , group = '<STR_LIT>' ) <EOL> filt_cls = metrics_filter . MetricsFilter ( ) <EOL> host = fakes . FakeHostState ( '<STR_LIT>' , '<STR_LIT>' , <EOL> attribute_dict = { '<STR_LIT>' : metrics_list } ) <EOL> self . assertFalse ( filt_cls . host_passes ( host , None ) ) </s>
