Updated Branches: refs/heads/4.2 5a57e82ea -> a14a9c192
CLOUDSTACK-2884: Fixed test_04_change_offering_small Added method to compare if two digits are almost equal within given range Signed-off-by: Prasanna Santhanam <[email protected]> (cherry picked from commit 048cf5aae84786d2d3515a3199271e87c0c7bafb) Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ee9e7230 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ee9e7230 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ee9e7230 Branch: refs/heads/4.2 Commit: ee9e7230222e9f63c617a2a7be1f39232f37562e Parents: 5a57e82 Author: Gaurav Aradhye <[email protected]> Authored: Wed Jul 3 23:37:52 2013 -0400 Committer: Prasanna Santhanam <[email protected]> Committed: Thu Jul 4 20:15:21 2013 +0530 ---------------------------------------------------------------------- .../integration/smoke/test_service_offerings.py | 23 +++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee9e7230/test/integration/smoke/test_service_offerings.py ---------------------------------------------------------------------- diff --git a/test/integration/smoke/test_service_offerings.py b/test/integration/smoke/test_service_offerings.py index 0213c04..8b6b013 100644 --- a/test/integration/smoke/test_service_offerings.py +++ b/test/integration/smoke/test_service_offerings.py @@ -273,6 +273,21 @@ class TestServiceOfferings(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return + def isAlmostEqual(self, first_digit, second_digit, range=0): + + digits_equal_within_range = False + + try: + if ((first_digit - range) < second_digit < (first_digit + range)): + digits_equal_within_range = True + + except Exception as e: + self.fail( + "%s: Failed while comparing the numbers %s & %s" % + (e, first_digit, second_digit)) + + return digits_equal_within_range + @attr(tags=["advanced", "advancedns", "smoke", "basic", "eip", "sg"]) def test_02_edit_service_offering(self): """Test to update existing service offering""" @@ -431,9 +446,11 @@ class TestServiceOfferings(cloudstackTestCase): self.small_offering.cpuspeed, "Check CPU Speed for small offering" ) - self.assertAlmostEqual( - int(total_mem) / 1024, # In MBs - int(self.small_offering.memory), + self.assertTrue( + self.isAlmostEqual(int(int(total_mem)/1024), + int(self.small_offering.memory), + range=20 + ), "Check Memory(kb) for small offering" ) return
