blob: 3136932f5cca9d6660598ed7d01835ae779a960d [file] [log] [blame]
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001"""
2Copyright 2013 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
adminbae64d82013-08-01 10:50:15 -07008
9 TestON is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070012 ( at your option ) any later version.
adminbae64d82013-08-01 10:50:15 -070013
14 TestON is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
Jon Hall4ba53f02015-07-29 13:07:41 -070020 along with TestON. If not, see <http://www.gnu.org/licenses/>.
adminbae64d82013-08-01 10:50:15 -070021
22
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070023"""
24class Assert:
adminbae64d82013-08-01 10:50:15 -070025
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070026 def __init__( self ):
adminbae64d82013-08-01 10:50:15 -070027 self.default = ''
28
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070029 def CASE1( self, main ):
adminbae64d82013-08-01 10:50:15 -070030
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070031 main.case( "Using assert to verify the result" )
32 main.step( "Using assert_equal to verify the result is equivalent or not" )
adminbae64d82013-08-01 10:50:15 -070033 expect = main.TRUE
34 actual = main.TRUE
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070035 main.log.warn(
36 main.response_parser( '<real></real><imag>2</imag><__complex__>true</__complex__>',
37 "json" ) )
38 utilities.assert_equals( expect=expect, actual=actual,
39 onpass="expect is equal to actual",
40 onfail="expect is not equal to actual" )
Jon Hall4ba53f02015-07-29 13:07:41 -070041
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070042 main.step( "Using assert_matches to verify the result matches or not" )
adminbae64d82013-08-01 10:50:15 -070043 expect = "Res(.*)"
44 actual = "Result"
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070045 utilities.assert_matches( expect=expect, actual=actual,
46 onpass="expect is macthes to actual",
47 onfail="expect is not matches to actual" )
Jon Hall4ba53f02015-07-29 13:07:41 -070048
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070049 main.step( "Using assert_greater to verify the result greater or not" )
adminbae64d82013-08-01 10:50:15 -070050 expect = 10
51 actual = 5
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070052 utilities.assert_greater( expect=actual, actual=expect,
53 onpass="expect is greater than the actual",
54 onfail="expect is not greater than the actual" )
Jon Hall4ba53f02015-07-29 13:07:41 -070055
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070056 main.step( "Using assert_lesser to verify the result lesser or not" )
adminbae64d82013-08-01 10:50:15 -070057 expect = 5
58 actual = 10
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070059 utilities.assert_lesser( expect=actual, actual=expect,
60 onpass="expect is lesser than the actual",
61 onfail="expect is not lesser than the actual" )