def test_compute_status_filter(self, mock_log): reqspec = objects.RequestSpec(flavor=objects.Flavor(extra_specs={})) request_filter.compute_status_filter(self.context, reqspec) # The forbidden trait should be added to the RequestSpec.flavor. self.assertEqual({'trait:COMPUTE_STATUS_DISABLED': 'forbidden'}, reqspec.flavor.extra_specs) # The RequestSpec.flavor changes should be reset so they are not # persisted. self.assertEqual(set(), reqspec.flavor.obj_what_changed()) # Assert both the in-method logging and trace decorator. log_lines = [c[0][0] for c in mock_log.debug.call_args_list] self.assertIn('added forbidden trait', log_lines[0]) self.assertIn('took %.1f seconds', log_lines[1])
def test_compute_status_filter(self, mock_log): reqspec = objects.RequestSpec(flavor=objects.Flavor(extra_specs={})) self.assertEqual(0, len(reqspec.root_required)) self.assertEqual(0, len(reqspec.root_forbidden)) # Request filter puts the trait into the request spec request_filter.compute_status_filter(self.context, reqspec) self.assertEqual(0, len(reqspec.root_required)) self.assertEqual({ot.COMPUTE_STATUS_DISABLED}, reqspec.root_forbidden) # Assert both the in-method logging and trace decorator. log_lines = [c[0][0] for c in mock_log.debug.call_args_list] self.assertIn('added forbidden trait', log_lines[0]) self.assertIn('took %.1f seconds', log_lines[1])