@@ -1010,3 +1010,51 @@ def test_to_str(self):
10101010 """Test that the object serializes to str properly."""
10111011 as_str = matchers .LessThanOrEqualToSemverMatcher (self .raw )
10121012 assert str (as_str ) == "less than or equal to semver 2.1.8"
1013+
1014+ class BetweenSemverMatcherTests (MatcherTestsBase ):
1015+ """Semver between matcher test cases."""
1016+
1017+ raw = {
1018+ 'negate' : False ,
1019+ 'matcherType' : 'BETWEEN_SEMVER' ,
1020+ 'betweenStringMatcherData' : {"start" : "2.1.8" , "end" : "2.1.11" }
1021+ }
1022+
1023+ def test_from_raw (self , mocker ):
1024+ """Test parsing from raw json/dict."""
1025+ parsed = matchers .from_raw (self .raw )
1026+ assert isinstance (parsed , matchers .BetweenSemverMatcher )
1027+ assert parsed ._data == {"start" : "2.1.8" , "end" : "2.1.11" }
1028+ assert isinstance (parsed ._semver_start , Semver )
1029+ assert isinstance (parsed ._semver_end , Semver )
1030+ assert parsed ._semver_start ._major == 2
1031+ assert parsed ._semver_start ._minor == 1
1032+ assert parsed ._semver_start ._patch == 8
1033+ assert parsed ._semver_start ._pre_release == []
1034+
1035+ assert parsed ._semver_end ._major == 2
1036+ assert parsed ._semver_end ._minor == 1
1037+ assert parsed ._semver_end ._patch == 11
1038+ assert parsed ._semver_end ._pre_release == []
1039+
1040+ def test_matcher_behaviour (self , mocker ):
1041+ """Test if the matcher works properly."""
1042+ parsed = matchers .from_raw (self .raw )
1043+ assert parsed ._match ("2.1.8+rc" )
1044+ assert parsed ._match ("2.1.9" )
1045+ assert parsed ._match ("2.1.11-rc12" )
1046+ assert not parsed ._match ("2.1.5" )
1047+ assert not parsed ._match ("2.1.12-rc1" )
1048+ assert not parsed ._match (None )
1049+ assert not parsed ._match ("semver" )
1050+
1051+ def test_to_json (self ):
1052+ """Test that the object serializes to JSON properly."""
1053+ as_json = matchers .BetweenSemverMatcher (self .raw ).to_json ()
1054+ assert as_json ['matcherType' ] == 'BETWEEN_SEMVER'
1055+ assert as_json ['betweenStringMatcherData' ] == {"start" : "2.1.8" , "end" : "2.1.11" }
1056+
1057+ def test_to_str (self ):
1058+ """Test that the object serializes to str properly."""
1059+ as_str = matchers .BetweenSemverMatcher (self .raw )
1060+ assert str (as_str ) == "between semver 2.1.8 and 2.1.11"
0 commit comments