Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2013 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 8 | |
| 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 Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 12 | ( at your option ) any later version. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 13 | |
| 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 Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 20 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 21 | |
| 22 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 23 | """ |
| 24 | class Assert: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 25 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 26 | def __init__( self ): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 27 | self.default = '' |
| 28 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 29 | def CASE1( self, main ): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 30 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 31 | main.case( "Using assert to verify the result" ) |
| 32 | main.step( "Using assert_equal to verify the result is equivalent or not" ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 33 | expect = main.TRUE |
| 34 | actual = main.TRUE |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 35 | 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 Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 41 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 42 | main.step( "Using assert_matches to verify the result matches or not" ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 43 | expect = "Res(.*)" |
| 44 | actual = "Result" |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 45 | utilities.assert_matches( expect=expect, actual=actual, |
| 46 | onpass="expect is macthes to actual", |
| 47 | onfail="expect is not matches to actual" ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 48 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 49 | main.step( "Using assert_greater to verify the result greater or not" ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 50 | expect = 10 |
| 51 | actual = 5 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 52 | 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 Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 55 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 56 | main.step( "Using assert_lesser to verify the result lesser or not" ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 57 | expect = 5 |
| 58 | actual = 10 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 59 | utilities.assert_lesser( expect=actual, actual=expect, |
| 60 | onpass="expect is lesser than the actual", |
| 61 | onfail="expect is not lesser than the actual" ) |