瀏覽代碼

Am example test file testing parts of the 'internet_mobile' location.

netuttki 10 月之前
父節點
當前提交
802765920d
共有 1 個文件被更改,包括 186 次插入0 次删除
  1. 186 0
      test/test_internet_mobile.qsrc

+ 186 - 0
test/test_internet_mobile.qsrc

@@ -0,0 +1,186 @@
+# test_internet_mobile
+!! ------------------------------------------------------------------------------------
+!! Location setup
+!! ------------------------------------------------------------------------------------
+!! @locationsetup
+
+_ISTEST = 1
+$LOCATIONNAME = 'internet_mobile'
+
+!! ------------------------------------------------------------------------------------
+!! Run the tests that are called below.
+!! ------------------------------------------------------------------------------------
+
+!! @run test_subscription_free_value_is_1
+!! @run 'test_buy_subscription_day_is_correct'
+!! @run 'test_buy_subscription_subscription_is_active'
+!! @run 'test_buy_subscription_price_is_correct'
+!! @run 'test_buy_subscription_type_is_correct'
+!! @run test_cancel_subscription 
+!! test_buy_subscription_for_invalid_location
+
+!! ------------------------------------------------------------------------------------
+!! Tests 
+!! ------------------------------------------------------------------------------------
+!! @tests 
+
+if $ARGS[0] = 'test_subscription_free_value_is_1':
+    $TESTNAME = "Testing that subscription['free'] has a value of 1 on the first call."
+    $FUNCTIONNAME = ''
+
+    if _ISVALIDCALL['<<$LOCATIONNAME>>,<<$FUNCTIONNAME>>'] ! 0:
+        gs 'testframework', 'testsetup'   
+        
+        EXPECTED = 1
+        $EXPECTED_MESSAGE = "subscription['free'] = <<EXPECTED>>"
+        
+        gs $LOCATIONNAME, $FUNCTIONNAME
+        *clr & cla 
+        
+        ACTUAL = subscription['free']
+        $ACTUAL_MESSAGE = "subscription['free'] = <<ACTUAL>>"
+        TESTRESULT = EXPECTED = ACTUAL
+    
+    else 
+        $ACTUAL_MESSAGE = '<<$LOCATIONNAME>> <<$FUNCTIONNAME>> does not exist.'
+    end
+    gs 'testframework', 'addTestResult'
+    gs 'testframework', 'testCleanUpDefault'
+    killvar 'subscription'
+end
+
+if $ARGS[0] = 'test_buy_subscription_day_is_correct':
+    $TESTNAME = 'Buying subscription sets the renewal day correctly'
+    $FUNCTIONNAME = 'buy_subscription'
+
+    if _ISVALIDCALL['<<$LOCATIONNAME>>,<<$FUNCTIONNAME>>'] ! 0:
+        gs 'testframework', 'testsetup'
+        EXPECTED = day
+        $EXPECTED_MESSAGE = "subscription['city_residential-date'] = <<EXPECTED>>"
+        
+        $ARGUMENTS = "'city_residential', 1200"
+        gs $LOCATIONNAME, $FUNCTIONNAME, 'city_residential', 1200
+         *clr & cla 
+        ACTUAL = subscription['city_residential-date']
+        $ACTUAL_MESSAGE = "subscription['city_residential-date'] = <<ACTUAL>>"
+
+        TESTRESULT = EXPECTED = ACTUAL  
+    else
+        $ACTUAL_MESSAGE = '<<$LOCATIONNAME>> <<$FUNCTIONNAME>> does not exist.'
+    end
+    gs 'testframework', 'addTestResult'
+    gs 'testframework', 'testCleanUpDefault'
+    killvar 'subscription'
+end  
+
+if $ARGS[0] = 'test_buy_subscription_subscription_is_active':
+    $TESTNAME = 'Buying a subscription makes the subscription active'
+    $FUNCTIONNAME = 'buy_subscription'
+
+    if _ISVALIDCALL['<<$LOCATIONNAME>>,<<$FUNCTIONNAME>>'] ! 0:
+        gs 'testframework', 'testsetup'
+        EXPECTED = 1
+        $EXPECTED_MESSAGE = "subscription['city_residential'] = <<EXPECTED>>"
+        
+        $ARGUMENTS = "'city_residential', 1200"
+        gs $LOCATIONNAME, $FUNCTIONNAME, 'city_residential', 1200
+         *clr & cla 
+        ACTUAL = subscription['city_residential']
+        $ACTUAL_MESSAGE = "subscription['city_residential'] = <<ACTUAL>>"
+
+        TESTRESULT = EXPECTED = ACTUAL  
+    else
+        $ACTUAL_MESSAGE = '<<$LOCATIONNAME>> <<$FUNCTIONNAME>> does not exist.'
+    end
+    gs 'testframework', 'addTestResult'
+    gs 'testframework', 'testCleanUpDefault'
+    killvar 'subscription'
+end  
+
+if $ARGS[0] = 'test_buy_subscription_price_is_correct':
+    $TESTNAME = 'Buying a subscription sets the price correctly'
+    $FUNCTIONNAME = 'buy_subscription'
+
+    if _ISVALIDCALL['<<$LOCATIONNAME>>,<<$FUNCTIONNAME>>'] ! 0:
+        gs 'testframework', 'testsetup'
+        EXPECTED = 1200
+        $EXPECTED_MESSAGE = "subscription['city_residential-price'] = <<EXPECTED>>"
+        
+        $ARGUMENTS = "'city_residential', 1200"
+        gs $LOCATIONNAME, $FUNCTIONNAME, 'city_residential', 1200
+         *clr & cla 
+        ACTUAL = subscription['city_residential-price']
+        $ACTUAL_MESSAGE = "subscription['city_residential-price'] = <<ACTUAL>>"
+
+        TESTRESULT = EXPECTED = ACTUAL  
+    else
+        $ACTUAL_MESSAGE = '<<$LOCATIONNAME>> <<$FUNCTIONNAME>> does not exist.'
+    end
+    gs 'testframework', 'addTestResult'
+    gs 'testframework', 'testCleanUpDefault'
+    killvar 'subscription'
+end  
+
+if $ARGS[0] = 'test_buy_subscription_type_is_correct':
+    $TESTNAME = 'Buying a subscription sets the subscription type correctly'
+    $FUNCTIONNAME = 'buy_subscription'
+
+    if _ISVALIDCALL['<<$LOCATIONNAME>>,<<$FUNCTIONNAME>>'] ! 0:
+        gs 'testframework', 'testsetup'
+        EXPECTED = 1
+        $EXPECTED_MESSAGE = "subscription['city_residential-type'] = <<EXPECTED>>"
+        
+        $ARGUMENTS = "'city_residential', 1200"
+        gs $LOCATIONNAME, $FUNCTIONNAME, 'city_residential', 1200
+         *clr & cla 
+        ACTUAL = subscription['city_residential-type']
+        $ACTUAL_MESSAGE = "subscription['city_residential-type'] = <<ACTUAL>>"
+
+        TESTRESULT = EXPECTED = ACTUAL  
+    else
+        $ACTUAL_MESSAGE = '<<$LOCATIONNAME>> <<$FUNCTIONNAME>> does not exist.'
+    end
+    gs 'testframework', 'addTestResult'
+    gs 'testframework', 'testCleanUpDefault'
+    killvar 'subscription'
+end
+
+if $ARGS[0] = 'test_cancel_subscription':
+    $TESTNAME = 'Cancelling an existing subscription'
+    $FUNCTIONNAME = 'cancel_subscription'
+   
+    if _ISVALIDCALL['<<$LOCATIONNAME>>,<<$FUNCTIONNAME>>'] ! 0:
+        gs 'testframework', 'testsetup'
+    
+        subscription['city_residential'] = 1
+        subscription['city_residential-date'] = 24
+        subscription['sms_limit'] = 0
+        subscription['city_residential-type'] = 1
+        subscription['city_residential-price'] = 1200
+        subscription['city_residential-discount'] = 0
+
+        EXPECTED = 0
+        $EXPECTED_MESSAGE = "subscription['city_residential'] = <<EXPECTED>>"
+        $ARGUMENTS = "'city_residential'"
+        gs $LOCATIONNAME, $FUNCTIONNAME, 'city_residential'
+!!        *clr & cla 
+        ACTUAL = subscription['city_residential']
+        $ACTUAL_MESSAGE = "subscription['city_residential'] = <<ACTUAL>>"
+ 
+        TESTRESULT = EXPECTED = ACTUAL
+  
+    else
+        $ACTUAL_MESSAGE = '<<$LOCATIONNAME>> <<$FUNCTIONNAME>> does not exist.'
+    end
+  
+    gs 'testframework', 'addTestResult' 
+    gs 'testframework', 'testCleanUpDefault'
+    killvar 'subscription'  
+end
+
+killvar 'LOCATIONNAME'
+killvar '_ISTEST'
+
+
+
+--- test_internet_mobile --------------------------------