Skip to content

Commit 73c792d

Browse files
committed
Add tests for existing filters
Signed-off-by: Webster Mudge <[email protected]>
1 parent 5fde0fb commit 73c792d

File tree

3 files changed

+103
-59
lines changed

3 files changed

+103
-59
lines changed

tests/unit/plugins/filter/test_core_exe.py

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
from __future__ import absolute_import, division, print_function
18+
19+
__metaclass__ = type
20+
21+
import pytest
22+
23+
from unittest import TestCase
24+
25+
26+
dataset = [
27+
(
28+
{"foo": "bar", "gaz": "blaz", "nested": {"duz": "ferr"}},
29+
{"gaz": "blergh", "derr": "zaar", "nested": {"wuz": "gug"}},
30+
False,
31+
{
32+
"foo": "bar",
33+
"gaz": "blaz",
34+
"derr": "zaar",
35+
"nested": {"duz": "ferr"},
36+
}
37+
),
38+
(
39+
{"foo": "bar", "gaz": "blaz", "nested": {"duz": "ferr"}},
40+
{"gaz": "blergh", "derr": "zaar", "nested": {"wuz": "gug"}},
41+
True,
42+
{
43+
"foo": "bar",
44+
"gaz": "blaz",
45+
"derr": "zaar",
46+
"nested": {"duz": "ferr", "wuz": "gug"},
47+
}
48+
),
49+
]
50+
51+
52+
@pytest.mark.parametrize("source,target,recursive,expected", dataset)
53+
def test_filter_version(filter, source, target, recursive, expected):
54+
onto_filter = filter("combine_onto")
55+
56+
actual = onto_filter([source, target], recursive=recursive)
57+
58+
TestCase().assertDictEqual(expected, actual)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
from __future__ import absolute_import, division, print_function
18+
19+
__metaclass__ = type
20+
21+
import pytest
22+
23+
24+
dataset = [
25+
("1.2.3", (1, 2, 3, None, None)),
26+
("1.2.3 SP1", (1, 2, 3, tuple(["SP1"]), None)),
27+
("1.2.3-SP1", (1, 2, 3, tuple(["SP1"]), None)),
28+
("1.2.3.SP1", (1, 2, 3, tuple(["SP1"]), None)),
29+
("1.2.3 SP1.400", (1, 2, 3, tuple(["SP1", 400]), None)),
30+
("1.2.3+Build", (1, 2, 3, None, tuple(["Build"]))),
31+
("1.2.3+Build.400", (1, 2, 3, None, tuple(["Build", 400]))),
32+
]
33+
34+
35+
@pytest.mark.parametrize("vstring,expected", dataset)
36+
def test_filter_version(filter, vstring, expected):
37+
version_filter = filter("version")
38+
39+
actual = version_filter(vstring)
40+
41+
assert actual.get("major") == expected[0]
42+
assert actual.get("minor") == expected[1]
43+
assert actual.get("patch") == expected[2]
44+
assert actual.get("prerelease") == expected[3]
45+
assert actual.get("buildmetadata") == expected[4]

0 commit comments

Comments
 (0)