@@ -968,3 +968,45 @@ def test_to_str(self):
968968 """Test that the object serializes to str properly."""
969969 as_str = matchers .GreaterThanOrEqualToSemverMatcher (self .raw )
970970 assert str (as_str ) == "greater than or equal to semver 2.1.8"
971+
972+ class LessThanOrEqualToSemverMatcherTests (MatcherTestsBase ):
973+ """Semver less or equalto matcher test cases."""
974+
975+ raw = {
976+ 'negate' : False ,
977+ 'matcherType' : 'LESS_THAN_OR_EQUAL_TO_SEMVER' ,
978+ 'stringMatcherData' : "2.1.8"
979+ }
980+
981+ def test_from_raw (self , mocker ):
982+ """Test parsing from raw json/dict."""
983+ parsed = matchers .from_raw (self .raw )
984+ assert isinstance (parsed , matchers .LessThanOrEqualToSemverMatcher )
985+ assert parsed ._data == "2.1.8"
986+ assert isinstance (parsed ._semver , Semver )
987+ assert parsed ._semver ._major == 2
988+ assert parsed ._semver ._minor == 1
989+ assert parsed ._semver ._patch == 8
990+ assert parsed ._semver ._pre_release == []
991+
992+ def test_matcher_behaviour (self , mocker ):
993+ """Test if the matcher works properly."""
994+ parsed = matchers .from_raw (self .raw )
995+ assert parsed ._match ("2.1.8+rc" )
996+ assert parsed ._match ("2.1.8" )
997+ assert not parsed ._match ("2.1.11" )
998+ assert parsed ._match ("2.1.5" )
999+ assert parsed ._match ("2.1.5-rc1" )
1000+ assert not parsed ._match (None )
1001+ assert not parsed ._match ("semver" )
1002+
1003+ def test_to_json (self ):
1004+ """Test that the object serializes to JSON properly."""
1005+ as_json = matchers .LessThanOrEqualToSemverMatcher (self .raw ).to_json ()
1006+ assert as_json ['matcherType' ] == 'LESS_THAN_OR_EQUAL_TO_SEMVER'
1007+ assert as_json ['stringMatcherData' ] == "2.1.8"
1008+
1009+ def test_to_str (self ):
1010+ """Test that the object serializes to str properly."""
1011+ as_str = matchers .LessThanOrEqualToSemverMatcher (self .raw )
1012+ assert str (as_str ) == "less than or equal to semver 2.1.8"
0 commit comments