@@ -64,13 +64,29 @@ def test_get_author_info_from_short_sha(subprocess_check_output):
64
64
assert get_author_info_from_short_sha ('22a594a' ) == 'Armin Rigo <armin.rigo@gmail.com>'
65
65
66
66
67
+ @pytest .mark .parametrize ('input_branches,sorted_branches' , [
68
+ (['3.1' , '2.7' , '3.10' , '3.6' ], ['3.10' , '3.6' , '3.1' , '2.7' ]),
69
+ (['stable-3.1' , 'lts-2.7' , '3.10-other' , 'smth3.6else' ], ['3.10-other' , 'smth3.6else' , 'stable-3.1' , 'lts-2.7' ]),
70
+ ])
67
71
@mock .patch ('os.path.exists' )
68
- def test_sorted_branch (os_path_exists , config ):
72
+ def test_sorted_branch (os_path_exists , config , input_branches , sorted_branches ):
69
73
os_path_exists .return_value = True
70
- branches = ["3.1" , "2.7" , "3.10" , "3.6" ]
71
74
cp = CherryPicker ('origin' , '22a594a0047d7706537ff2ac676cdc0f1dcb329c' ,
72
- branches , config = config )
73
- assert cp .sorted_branches == ["3.10" , "3.6" , "3.1" , "2.7" ]
75
+ input_branches , config = config )
76
+ assert cp .sorted_branches == sorted_branches
77
+
78
+
79
+ @pytest .mark .parametrize ('input_branches' , [
80
+ (['3.1' , '2.7' , '3.x10' , '3.6' , '' ]),
81
+ (['stable-3.1' , 'lts-2.7' , '3.10-other' , 'smth3.6else' , 'invalid' ]),
82
+ ])
83
+ @mock .patch ('os.path.exists' )
84
+ def test_invalid_branches (os_path_exists , config , input_branches ):
85
+ os_path_exists .return_value = True
86
+ cp = CherryPicker ('origin' , '22a594a0047d7706537ff2ac676cdc0f1dcb329c' ,
87
+ input_branches , config = config )
88
+ with pytest .raises (ValueError ):
89
+ cp .sorted_branches
74
90
75
91
76
92
@mock .patch ('os.path.exists' )
0 commit comments