1 # Copyright (C) 2023 Wind River Systems, Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from o2ims.service.command import notify_handler
17 def test_handle_filter():
18 assert notify_handler.handle_filter(
19 "(eq,resourceId,resid1234)", "ResourceInfo") == (
20 1, ['(eq,resourceId,resid1234)'])
21 assert notify_handler.handle_filter(
22 "[(eq,objectType,ResourceInfo);(eq,resourceId,resid1234)]",
24 1, ['(eq,objectType,ResourceInfo);(eq,resourceId,resid1234)'])
25 assert notify_handler.handle_filter(
26 "[eq,objectType,ResourceTypeInfo|eq,objectType,ResourcePoolInfo]",
27 "ResourceInfo") == (0, [])
28 assert notify_handler.handle_filter(
29 "", "ResourceInfo") is None
30 assert notify_handler.handle_filter(
31 "", "ResourceTypeInfo") is None
32 assert notify_handler.handle_filter(
33 "[eq,objectType,ResourceInfo|eq,objectType,ResourceTypeInfo]",
34 "ResourceInfo") == (1, ['eq,objectType,ResourceInfo'])
35 assert notify_handler.handle_filter(
36 "[(eq,objectType,ResourceInfo);(eq,resourceId,resourceid1234) | " +
37 "(eq,objectType,ResourceInfo);(eq,resourceTypeId,restype1234)",
39 (2, ['(eq,objectType,ResourceInfo);(eq,resourceId,resourceid1234) ',
40 ' (eq,objectType,ResourceInfo);(eq,resourceTypeId,restype1234)'
42 assert notify_handler.handle_filter(
43 "(eq,objectType,ResourceTypeInfo)|(eq,objectType,ResourcePoolInfo)" +
44 "|(eq,objectType,CloudInfo)|(eq,objectType,ResourceInfo)",
45 "DeploymentManagerInfo"
48 assert notify_handler.handle_filter(
49 "(eq,objectType,ResourceInfo)", "ResourceInfo") == (
50 1, ['(eq,objectType,ResourceInfo)'])