コード例 #1
0
    def test_tick_history_forex(self):
        input1 = json.dumps({
            "ticks_history": "frxAUDJPY",
            "end": "latest",
            "start": 1,
            "style": "ticks",
            "adjust_start_time": 1,
            "count": 10
        })

        tick_history_output1 = tu.send_and_receive_ws_x_authorize(input1)
        last_tick_time1 = tick_history_output1["history"]["times"][-1]

        time.sleep(2)

        input2 = json.dumps({
            "ticks_history": "R_50",
            "end": "latest",
            "start": 1,
            "style": "ticks",
            "adjust_start_time": 1,
            "count": 10
        })

        tick_history_output2 = tu.send_and_receive_ws_x_authorize(input2)

        last_tick_time2 = tick_history_output2["history"]["times"][-1]

        # make sure last tick is the latest
        self.assertTrue(last_tick_time2 > last_tick_time1)

        # make sure it returns 10 history
        self.assertTrue(len(tick_history_output2["history"]["times"]), 10)
        self.assertTrue(len(tick_history_output2["history"]["prices"]), 10)
        self.assertTrue('error' not in tick_history_output2)
コード例 #2
0
 def setUp(self):
     tu.log_out()
     # to forget all (this is needed in case some test cases are failing
     # and thus forgot is not done on the test cases)
     json_data = json.dumps({'forget_all': 'ticks'})
     tu.send_and_receive_ws_x_authorize(json_data)
     json_data = json.dumps({'forget_all': 'proposal'})
     tu.send_and_receive_ws_x_authorize(json_data)
コード例 #3
0
ファイル: TestxForget.py プロジェクト: meeyun-deriv/APItest
    def test_forget_proposal(self):
        # subscribe proposal API
        proposal_call = self.proposal_call_put_subscribe(
            "R_100", "CALL", 5, "d")
        output_call = tu.send_and_receive_ws_x_authorize(proposal_call)
        proposal_id = output_call["proposal"]["id"]

        forget = json.dumps({'forget': proposal_id})
        forget_output = tu.send_and_receive_ws_x_authorize(forget)

        self.assertEqual(forget_output["forget"], 1)
        self.assertTrue('error' not in forget_output)
コード例 #4
0
    def tearDown(self):
        tu.log_out()
        # to forget all (this is needed in case some test cases are failing
        # and thus forgot is not done on the test cases)
        json_data = json.dumps({'forget_all': 'ticks'})
        tu.send_and_receive_ws_x_authorize(json_data)
        json_data = json.dumps({'forget_all': 'proposal'})
        tu.send_and_receive_ws_x_authorize(json_data)

        time.sleep(
            1
        )  # in case the script running too fast and next detected call is forget all
コード例 #5
0
    def assert_forget_all(self, data, forget_value, json_key):
        output = tu.send_and_receive_ws_x_authorize(data)
        output_id = output[json_key]["id"]

        # send forget all - tick
        forget_all = json.dumps({'forget_all': forget_value})
        forget_output = tu.send_and_receive_ws_x_authorize(forget_all)
        forget_output_id = forget_output["forget_all"][0]

        # the subscribe id and forget id should be the same
        self.assertEqual(output_id, forget_output_id)
        self.assertTrue('error' not in forget_output)
コード例 #6
0
    def assert_landing_company_details(self, input, expected_data):
        landing_company_details = tu.send_and_receive_ws_x_authorize(input)
        expected_landing_company_details = self.get_prod_output(input)

        self.assertTrue(
            tu.compare_data(landing_company_details,
                            expected_landing_company_details),
            "Unmatch result")
コード例 #7
0
    def assert_landing_company(self, input, expected_data):
        landing_company_input = tu.send_and_receive_ws_x_authorize(input)

        expected_output = self.get_prod_output(input)
        expected_landing_company = tu.convert_py_json_output(expected_output)


        self.assertTrue(tu.compare_data(landing_company_input, expected_landing_company), "Unmatch result")
コード例 #8
0
    def test_landing_company_details_invalid(self):
        landing_company_details = json.dumps(
            {"landing_company_details": "invalid"})

        landing_company_details_invalid = tu.send_and_receive_ws_x_authorize(
            landing_company_details)

        self.assertTrue('error' in landing_company_details_invalid)
        self.assertTrue('Input validation failed: landing_company_details' in
                        landing_company_details_invalid['error']['message'])
コード例 #9
0
    def send_and_receive_exchange(self, base_currency):
        input = json.dumps({
            "exchange_rates": 1,
            "base_currency": base_currency

        })

        usd_exchange = tu.send_and_receive_ws_x_authorize(input)

        return usd_exchange
コード例 #10
0
    def test_server_time(self):
        input = json.dumps({"time": 1})

        server_time_response = tu.send_and_receive_ws_x_authorize(input)

        epoch_time = server_time_response["time"]
        current_time = int(time.time())

        self.assertAlmostEqual(epoch_time, current_time, delta=2)
        self.assertTrue('error' not in server_time_response)
コード例 #11
0
    def test_asset_index_invalid_landing_company(self):
        asset_index = json.dumps({
            "asset_index": 1,
            "landing_company": "invalid"
        })

        asset_index_invalid = tu.send_and_receive_ws_x_authorize(asset_index)

        self.assertTrue('error' in asset_index_invalid)
        self.assertTrue('Input validation failed: landing_company' in
                        asset_index_invalid['error']['message'])
コード例 #12
0
    def test_forget_all_ticks_without_subscribe(self):
        json_data = json.dumps({'forget_all': 'ticks'})
        result_js = tu.send_and_receive_ws_x_authorize(json_data)

        forget_all = result_js['forget_all']
        msg_type = result_js["msg_type"]

        expected_forget_all = []
        expected_msg_type = "forget_all"

        self.assertEqual(forget_all, expected_forget_all)
        self.assertEqual(msg_type, expected_msg_type)
コード例 #13
0
    def compare(self, input):
        # prod
        json_data = json.dumps(input)
        tu.prod_ws.send(json_data)
        result_str = tu.prod_ws.recv()
        result_prod = json.loads(result_str)

        # qa
        json_data = json.dumps(input)
        result_qa = tu.send_and_receive_ws_x_authorize(json_data)

        self.assertEqual(result_qa, result_prod)
コード例 #14
0
    def test_forget_all_multiple_proposals(self):
        # subscribe multiple proposal API
        proposal_call = self.proposal_call_put_subscribe(
            "R_100", "CALL", 5, "d")
        output_call = tu.send_and_receive_ws_x_authorize(proposal_call)
        proposal_put = self.proposal_call_put_subscribe("R_100", "PUT", 5, "d")
        output_put = tu.send_and_receive_ws_x_authorize(proposal_put)

        # save the both proposal id in the list
        output_id_list = []
        output_id_list.extend(
            (output_call["proposal"]["id"], output_put["proposal"]["id"]))

        forget_all = json.dumps({'forget_all': "proposal"})
        forget_output = tu.send_and_receive_ws_x_authorize(forget_all)
        forget_output_id = forget_output["forget_all"]

        # output_id_list and forget_output_id should have same list
        same_forget_id = [
            item for item in output_id_list if item in forget_output_id
        ]

        self.assertEqual(len(same_forget_id), 2)
        self.assertTrue('error' not in forget_output)
コード例 #15
0
    def test_tick_history_candle_future_date(self):
        end = tu.time_delta(+5, 'y')
        input = json.dumps({
            "ticks_history": "R_50",
            "end": end,
            "start": 1,
            "style": "candles",
            "adjust_start_time": 1,
            "count": 10
        })

        tick_history_output = tu.send_and_receive_ws_x_authorize(input)

        self.assertTrue('error' not in tick_history_output)
        # make sure it returns 10 candles
        self.assertTrue(len(tick_history_output["candles"]), 10)
コード例 #16
0
    def test_website_status(self):
        tu.log_out()  # log out so it will return client country as my

        input = json.dumps({"website_status": 1})

        website_status_response = tu.send_and_receive_ws_x_authorize(input)

        prod_output = self.get_prod_output(input)

        # to convert python structure same as json output
        expected_website_status = tu.convert_py_json_output(prod_output)

        # Without authenticate token, it will return clients_country: my, or else, follow the account country
        self.assertTrue(
            tu.compare_data(website_status_response, expected_website_status))
        self.assertTrue('error' not in website_status_response)
コード例 #17
0
    def test_tick_stream_vol(self):

        json_data = json.dumps({"ticks": "R_100", "subscribe": 1})
        result_js = tu.send_and_receive_ws_x_authorize(json_data)

        count = 1
        result = []

        while 'error' not in result_js and count <= 5:
            print("Stream tick number ", count)
            output = tu.ws.recv()
            # print(output)
            result.append(output)
            count += 1

        self.assertTrue('error' not in result_js)
        self.assertEqual(count, 6, "Tick is less than 5 in 30 seconds")
        if count == 1:
            print("Tick is not streaming at all")
コード例 #18
0
    def test_ping(self):
        ping = json.dumps({"ping": 1})

        ping_reponse = tu.send_and_receive_ws_x_authorize(ping)

        # remember to convert empty dict {} to None, else, result will fail ( {}!=None )
        expected_ping = {
            "echo_req": {
                "ping": 1
            },
            "msg_type": "ping",
            "ping": "pong"
        }

        # to convert python structure same as json output
        expected_ping_ = json.dumps(expected_ping)
        expected_ping_reponse = json.loads(expected_ping_)

        self.assertTrue(tu.compare_data(ping_reponse, expected_ping_reponse))
コード例 #19
0
    def test_payout_currencies(self):
        # Note this test case is design for unauthorise call.
        # If token is authenticated, it will return the currency which available for his account
        expected_payout_currencies = [
            "AUD", "BCH", "BTC", "DAI", "ETH", "EUR", "GBP", "LTC", "USD",
            "UST"
        ]

        payout_currencies = json.dumps({"payout_currencies": 1})

        tu.log_out(
        )  # log out so it will return full available payout currencies
        payout_currencies_reponse = tu.send_and_receive_ws_x_authorize(
            payout_currencies)

        payout_currencies_list = payout_currencies_reponse["payout_currencies"]

        self.assertTrue(
            set(expected_payout_currencies) == set(payout_currencies_list))
        self.assertTrue("error" not in payout_currencies_reponse)
コード例 #20
0
    def test_tick_history_custom_start_end(self):
        # # get the current epoch time
        end = int(time.time())
        start = tu.time_delta(-10, 'm')

        input = json.dumps({
            "ticks_history": "R_50",
            "end": end,
            "start": start,
            "style": "ticks",
            "adjust_start_time": 1
        })

        tick_history_output = tu.send_and_receive_ws_x_authorize(input)

        for item in tick_history_output["history"]["times"]:
            # convert unicode to int
            item = int(item)
            self.assertTrue(end >= item >= start)

        self.assertTrue(len(tick_history_output["history"]["times"]) != 0)
コード例 #21
0
    def test_tick_stream_forex(self):
        check_trading_day = datetime.datetime.today().weekday()

        if check_trading_day < 5:
            json_data = json.dumps({"ticks": "frxAUDJPY", "subscribe": 1})
            result_js = tu.send_and_receive_ws_x_authorize(json_data)

            count = 1
            result = []

            # while 'error' not in result_js:
            while 'error' not in result_js and count <= 5:
                print("Stream tick number ", count)
                output = tu.ws.recv()
                result.append(output)
                count += 1

            self.assertTrue('error' not in result_js)
            self.assertEqual(count, 6, "Tick is less than 5 in 30 seconds")

        else:

            print("Skipped test due to weekend")
コード例 #22
0
ファイル: TestxForget.py プロジェクト: meeyun-deriv/APItest
 def tearDown(self):
     # to forget all (this is needed in case some test cases are failing
     # and thus forgot is not done on the test cases)
     json_data = json.dumps({'forget_all': 'proposal'})
     tu.send_and_receive_ws_x_authorize(json_data)
     return
コード例 #23
0
    def test_state_list_gb(self):
        expected_state_list = {
            "echo_req": {
                "states_list": "gb"
            },
            "msg_type":
            "states_list",
            "states_list": [{
                "text": "Aberdeen City",
                "value": "ABE"
            }, {
                "text": "Aberdeenshire",
                "value": "ABD"
            }, {
                "text": "Angus",
                "value": "ANS"
            }, {
                "text": "Antrim",
                "value": "ANT"
            }, {
                "text": "Ards",
                "value": "ARD"
            }, {
                "text": "Argyll and Bute",
                "value": "AGB"
            }, {
                "text": "Armagh",
                "value": "ARM"
            }, {
                "text": "Ballymena",
                "value": "BLA"
            }, {
                "text": "Ballymoney",
                "value": "BLY"
            }, {
                "text": "Banbridge",
                "value": "BNB"
            }, {
                "text": "Barking and Dagenham",
                "value": "BDG"
            }, {
                "text": "Barnet",
                "value": "BNE"
            }, {
                "text": "Barnsley",
                "value": "BNS"
            }, {
                "text": "Bath and North East Somerset",
                "value": "BAS"
            }, {
                "text": "Bedfordshire",
                "value": "BDF"
            }, {
                "text": "Belfast",
                "value": "BFS"
            }, {
                "text": "Bexley",
                "value": "BEX"
            }, {
                "text": "Birmingham",
                "value": "BIR"
            }, {
                "text": "Blackburn with Darwen",
                "value": "BBD"
            }, {
                "text": "Blackpool",
                "value": "BPL"
            }, {
                "text": "Blaenau Gwent",
                "value": "BGW"
            }, {
                "text": "Bolton",
                "value": "BOL"
            }, {
                "text": "Bournemouth",
                "value": "BMH"
            }, {
                "text": "Bracknell Forest",
                "value": "BRC"
            }, {
                "text": "Bradford",
                "value": "BRD"
            }, {
                "text": "Brent",
                "value": "BEN"
            }, {
                "text": "Bridgend",
                "value": "BGE"
            }, {
                "text": "Brighton and Hove",
                "value": "BNH"
            }, {
                "text": "Bristol, City of",
                "value": "BST"
            }, {
                "text": "Bromley",
                "value": "BRY"
            }, {
                "text": "Buckinghamshire",
                "value": "BKM"
            }, {
                "text": "Bury",
                "value": "BUR"
            }, {
                "text": "Caerphilly",
                "value": "CAY"
            }, {
                "text": "Calderdale",
                "value": "CLD"
            }, {
                "text": "Cambridgeshire",
                "value": "CAM"
            }, {
                "text": "Camden",
                "value": "CMD"
            }, {
                "text": "Cardiff",
                "value": "CRF"
            }, {
                "text": "Carmarthenshire",
                "value": "CMN"
            }, {
                "text": "Carrickfergus",
                "value": "CKF"
            }, {
                "text": "Castlereagh",
                "value": "CSR"
            }, {
                "text": "Ceredigion",
                "value": "CGN"
            }, {
                "text": "Cheshire",
                "value": "CHS"
            }, {
                "text": "Clackmannanshire",
                "value": "CLK"
            }, {
                "text": "Coleraine",
                "value": "CLR"
            }, {
                "text": "Conwy",
                "value": "CWY"
            }, {
                "text": "Cookstown",
                "value": "CKT"
            }, {
                "text": "Cornwall",
                "value": "CON"
            }, {
                "text": "Coventry",
                "value": "COV"
            }, {
                "text": "Craigavon",
                "value": "CGV"
            }, {
                "text": "Croydon",
                "value": "CRY"
            }, {
                "text": "Cumbria",
                "value": "CMA"
            }, {
                "text": "Darlington",
                "value": "DAL"
            }, {
                "text": "Denbighshire",
                "value": "DEN"
            }, {
                "text": "Derby",
                "value": "DER"
            }, {
                "text": "Derbyshire",
                "value": "DBY"
            }, {
                "text": "Derry",
                "value": "DRY"
            }, {
                "text": "Devon",
                "value": "DEV"
            }, {
                "text": "Doncaster",
                "value": "DNC"
            }, {
                "text": "Dorset",
                "value": "DOR"
            }, {
                "text": "Down",
                "value": "DOW"
            }, {
                "text": "Dudley",
                "value": "DUD"
            }, {
                "text": "Dumfries and Galloway",
                "value": "DGY"
            }, {
                "text": "Dundee City",
                "value": "DND"
            }, {
                "text": "Dungannon",
                "value": "DGN"
            }, {
                "text": "Durham",
                "value": "DUR"
            }, {
                "text": "Ealing",
                "value": "EAL"
            }, {
                "text": "East Ayrshire",
                "value": "EAY"
            }, {
                "text": "East Dunbartonshire",
                "value": "EDU"
            }, {
                "text": "East Lothian",
                "value": "ELN"
            }, {
                "text": "East Renfrewshire",
                "value": "ERW"
            }, {
                "text": "East Riding of Yorkshire",
                "value": "ERY"
            }, {
                "text": "East Sussex",
                "value": "ESX"
            }, {
                "text": "Edinburgh, City of",
                "value": "EDH"
            }, {
                "text": "Eilean Siar",
                "value": "ELS"
            }, {
                "text": "Enfield",
                "value": "ENF"
            }, {
                "text": "Essex",
                "value": "ESS"
            }, {
                "text": "Falkirk",
                "value": "FAL"
            }, {
                "text": "Fermanagh",
                "value": "FER"
            }, {
                "text": "Fife",
                "value": "FIF"
            }, {
                "text": "Flintshire",
                "value": "FLN"
            }, {
                "text": "Gateshead",
                "value": "GAT"
            }, {
                "text": "Glasgow City",
                "value": "GLG"
            }, {
                "text": "Gloucestershire",
                "value": "GLS"
            }, {
                "text": "Greenwich",
                "value": "GRE"
            }, {
                "text": "Guernsey",
                "value": "GSY"
            }, {
                "text": "Gwynedd",
                "value": "GWN"
            }, {
                "text": "Hackney",
                "value": "HCK"
            }, {
                "text": "Halton",
                "value": "HAL"
            }, {
                "text": "Hammersmith and Fulham",
                "value": "HMF"
            }, {
                "text": "Hampshire",
                "value": "HAM"
            }, {
                "text": "Haringey",
                "value": "HRY"
            }, {
                "text": "Harrow",
                "value": "HRW"
            }, {
                "text": "Hartlepool",
                "value": "HPL"
            }, {
                "text": "Havering",
                "value": "HAV"
            }, {
                "text": "Herefordshire, County of",
                "value": "HEF"
            }, {
                "text": "Hertfordshire",
                "value": "HRT"
            }, {
                "text": "Highland",
                "value": "HLD"
            }, {
                "text": "Hillingdon",
                "value": "HIL"
            }, {
                "text": "Hounslow",
                "value": "HNS"
            }, {
                "text": "Inverclyde",
                "value": "IVC"
            }, {
                "text": "Isle of Anglesey",
                "value": "AGY"
            }, {
                "text": "Isle of Wight",
                "value": "IOW"
            }, {
                "text": "Isles of Scilly",
                "value": "IOS"
            }, {
                "text": "Islington",
                "value": "ISL"
            }, {
                "text": "Jersey",
                "value": "JSY"
            }, {
                "text": "Kensington and Chelsea",
                "value": "KEC"
            }, {
                "text": "Kent",
                "value": "KEN"
            }, {
                "text": "Kingston upon Hull, City of",
                "value": "KHL"
            }, {
                "text": "Kingston upon Thames",
                "value": "KTT"
            }, {
                "text": "Kirklees",
                "value": "KIR"
            }, {
                "text": "Knowsley",
                "value": "KWL"
            }, {
                "text": "Lambeth",
                "value": "LBH"
            }, {
                "text": "Lancashire",
                "value": "LAN"
            }, {
                "text": "Larne",
                "value": "LRN"
            }, {
                "text": "Leeds",
                "value": "LDS"
            }, {
                "text": "Leicester",
                "value": "LCE"
            }, {
                "text": "Leicestershire",
                "value": "LEC"
            }, {
                "text": "Lewisham",
                "value": "LEW"
            }, {
                "text": "Limavady",
                "value": "LMV"
            }, {
                "text": "Lincolnshire",
                "value": "LIN"
            }, {
                "text": "Lisburn",
                "value": "LSB"
            }, {
                "text": "Liverpool",
                "value": "LIV"
            }, {
                "text": "London, City of",
                "value": "LND"
            }, {
                "text": "Luton",
                "value": "LUT"
            }, {
                "text": "Magherafelt",
                "value": "MFT"
            }, {
                "text": "Manchester",
                "value": "MAN"
            }, {
                "text": "Medway",
                "value": "MDW"
            }, {
                "text": "Merthyr Tydfil",
                "value": "MTY"
            }, {
                "text": "Merton",
                "value": "MRT"
            }, {
                "text": "Middlesbrough",
                "value": "MDB"
            }, {
                "text": "Midlothian",
                "value": "MLN"
            }, {
                "text": "Milton Keynes",
                "value": "MIK"
            }, {
                "text": "Monmouthshire [Sir Fynwy GB-FYN]",
                "value": "MON"
            }, {
                "text": "Moray",
                "value": "MRY"
            }, {
                "text": "Moyle",
                "value": "MYL"
            }, {
                "text": "Neath Port Talbot",
                "value": "NTL"
            }, {
                "text": "Newcastle upon Tyne",
                "value": "NET"
            }, {
                "text": "Newham",
                "value": "NWM"
            }, {
                "text": "Newport",
                "value": "NWP"
            }, {
                "text": "Newry and Mourne",
                "value": "NYM"
            }, {
                "text": "Newtownabbey",
                "value": "NTA"
            }, {
                "text": "Norfolk",
                "value": "NFK"
            }, {
                "text": "North Ayrshire",
                "value": "NAY"
            }, {
                "text": "North Down",
                "value": "NDN"
            }, {
                "text": "North East Lincolnshire",
                "value": "NEL"
            }, {
                "text": "North Lanarkshire",
                "value": "NLK"
            }, {
                "text": "North Lincolnshire",
                "value": "NLN"
            }, {
                "text": "North Somerset",
                "value": "NSM"
            }, {
                "text": "North Tyneside",
                "value": "NTY"
            }, {
                "text": "North Yorkshire",
                "value": "NYK"
            }, {
                "text": "Northamptonshire",
                "value": "NTH"
            }, {
                "text": "Northumberland",
                "value": "NBL"
            }, {
                "text": "Nottingham",
                "value": "NGM"
            }, {
                "text": "Nottinghamshire",
                "value": "NTT"
            }, {
                "text": "Oldham",
                "value": "OLD"
            }, {
                "text": "Omagh",
                "value": "OMH"
            }, {
                "text": "Orkney Islands",
                "value": "ORK"
            }, {
                "text": "Oxfordshire",
                "value": "OXF"
            }, {
                "text": "Pembrokeshire",
                "value": "PEM"
            }, {
                "text": "Perth and Kinross",
                "value": "PKN"
            }, {
                "text": "Peterborough",
                "value": "PTE"
            }, {
                "text": "Plymouth",
                "value": "PLY"
            }, {
                "text": "Poole",
                "value": "POL"
            }, {
                "text": "Portsmouth",
                "value": "POR"
            }, {
                "text": "Powys",
                "value": "POW"
            }, {
                "text": "Reading",
                "value": "RDG"
            }, {
                "text": "Redbridge",
                "value": "RDB"
            }, {
                "text": "Redcar and Cleveland",
                "value": "RCC"
            }, {
                "text": "Renfrewshire",
                "value": "RFW"
            }, {
                "text": "Rhondda, Cynon, Taff",
                "value": "RCT"
            }, {
                "text": "Richmond upon Thames",
                "value": "RIC"
            }, {
                "text": "Rochdale",
                "value": "RCH"
            }, {
                "text": "Rotherham",
                "value": "ROT"
            }, {
                "text": "Rutland",
                "value": "RUT"
            }, {
                "text": "Saint Helens",
                "value": "SHN"
            }, {
                "text": "Salford",
                "value": "SLF"
            }, {
                "text": "Sandwell",
                "value": "SAW"
            }, {
                "text": "Scottish Borders, The",
                "value": "SCB"
            }, {
                "text": "Sefton",
                "value": "SFT"
            }, {
                "text": "Sheffield",
                "value": "SHF"
            }, {
                "text": "Shetland Islands",
                "value": "ZET"
            }, {
                "text": "Shropshire",
                "value": "SHR"
            }, {
                "text": "Slough",
                "value": "SLG"
            }, {
                "text": "Solihull",
                "value": "SOL"
            }, {
                "text": "Somerset",
                "value": "SOM"
            }, {
                "text": "South Ayrshire",
                "value": "SAY"
            }, {
                "text": "South Gloucestershire",
                "value": "SGC"
            }, {
                "text": "South Lanarkshire",
                "value": "SLK"
            }, {
                "text": "South Tyneside",
                "value": "STY"
            }, {
                "text": "Southampton",
                "value": "STH"
            }, {
                "text": "Southend-on-Sea",
                "value": "SOS"
            }, {
                "text": "Southwark",
                "value": "SWK"
            }, {
                "text": "Staffordshire",
                "value": "STS"
            }, {
                "text": "Stirling",
                "value": "STG"
            }, {
                "text": "Stockport",
                "value": "SKP"
            }, {
                "text": "Stockton-on-Tees",
                "value": "STT"
            }, {
                "text": "Stoke-on-Trent",
                "value": "STE"
            }, {
                "text": "Strabane",
                "value": "STB"
            }, {
                "text": "Suffolk",
                "value": "SFK"
            }, {
                "text": "Sunderland",
                "value": "SND"
            }, {
                "text": "Surrey",
                "value": "SRY"
            }, {
                "text": "Sutton",
                "value": "STN"
            }, {
                "text": "Swansea",
                "value": "SWA"
            }, {
                "text": "Swindon",
                "value": "SWD"
            }, {
                "text": "Tameside",
                "value": "TAM"
            }, {
                "text": "Telford and Wrekin",
                "value": "TFW"
            }, {
                "text": "Thurrock",
                "value": "THR"
            }, {
                "text": "Torbay",
                "value": "TOB"
            }, {
                "text": "Torfaen",
                "value": "TOF"
            }, {
                "text": "Tower Hamlets",
                "value": "TWH"
            }, {
                "text": "Trafford",
                "value": "TRF"
            }, {
                "text": "Vale of Glamorgan",
                "value": "VGL"
            }, {
                "text": "Wakefield",
                "value": "WKF"
            }, {
                "text": "Walsall",
                "value": "WLL"
            }, {
                "text": "Waltham Forest",
                "value": "WFT"
            }, {
                "text": "Wandsworth",
                "value": "WND"
            }, {
                "text": "Warrington",
                "value": "WRT"
            }, {
                "text": "Warwickshire",
                "value": "WAR"
            }, {
                "text": "West Berkshire",
                "value": "WBK"
            }, {
                "text": "West Dunbartonshire",
                "value": "WDU"
            }, {
                "text": "West Lothian",
                "value": "WLN"
            }, {
                "text": "West Sussex",
                "value": "WSX"
            }, {
                "text": "Westminster",
                "value": "WSM"
            }, {
                "text": "Wigan",
                "value": "WGN"
            }, {
                "text": "Wiltshire",
                "value": "WIL"
            }, {
                "text": "Windsor and Maidenhead",
                "value": "WNM"
            }, {
                "text": "Wirral",
                "value": "WRL"
            }, {
                "text": "Wokingham",
                "value": "WOK"
            }, {
                "text": "Wolverhampton",
                "value": "WLV"
            }, {
                "text": "Worcestershire",
                "value": "WOR"
            }, {
                "text": "Wrexham",
                "value": "WRX"
            }, {
                "text": "York",
                "value": "YOR"
            }]
        }

        # to convert python structure same as json output
        expected_state_list_gb = tu.convert_py_json_output(expected_state_list)

        state_list = json.dumps({"states_list": "gb"})

        state_list_id = tu.send_and_receive_ws_x_authorize(state_list)

        self.assertTrue(tu.compare_data(state_list_id, expected_state_list_gb))
        self.assertTrue('error' not in state_list_id)
コード例 #24
0
    def test_state_list_id(self):
        expected_state_list = {
            "echo_req": {
                "states_list": "id"
            },
            "msg_type":
            "states_list",
            "states_list": [{
                "text": "Aceh",
                "value": "AC"
            }, {
                "text": "Bali",
                "value": "BA"
            }, {
                "text": "Bangka Belitung",
                "value": "BB"
            }, {
                "text": "Banten",
                "value": "BT"
            }, {
                "text": "Bengkulu",
                "value": "BE"
            }, {
                "text": "Gorontalo",
                "value": "GO"
            }, {
                "text": "Jakarta Raya",
                "value": "JK"
            }, {
                "text": "Jambi",
                "value": "JA"
            }, {
                "text": "Jawa Barat",
                "value": "JB"
            }, {
                "text": "Jawa Tengah",
                "value": "JT"
            }, {
                "text": "Jawa Timur",
                "value": "JI"
            }, {
                "text": "Kalimantan Barat",
                "value": "KB"
            }, {
                "text": "Kalimantan Selatan",
                "value": "KS"
            }, {
                "text": "Kalimantan Tengah",
                "value": "KT"
            }, {
                "text": "Kalimantan Timur",
                "value": "KI"
            }, {
                "text": "Kepulauan Riau",
                "value": "KR"
            }, {
                "text": "Lampung",
                "value": "LA"
            }, {
                "text": "Maluku",
                "value": "MA"
            }, {
                "text": "Maluku Utara",
                "value": "MU"
            }, {
                "text": "Nusa Tenggara Barat",
                "value": "NB"
            }, {
                "text": "Nusa Tenggara Timur",
                "value": "NT"
            }, {
                "text": "Papua",
                "value": "PA"
            }, {
                "text": "Papua Barat",
                "value": "PB"
            }, {
                "text": "Riau",
                "value": "RI"
            }, {
                "text": "Sulawesi Barat",
                "value": "SR"
            }, {
                "text": "Sulawesi Selatan",
                "value": "SN"
            }, {
                "text": "Sulawesi Tengah",
                "value": "ST"
            }, {
                "text": "Sulawesi Tenggara",
                "value": "SG"
            }, {
                "text": "Sulawesi Utara",
                "value": "SA"
            }, {
                "text": "Sumatera Barat",
                "value": "SB"
            }, {
                "text": "Sumatera Selatan",
                "value": "SS"
            }, {
                "text": "Sumatera Utara",
                "value": "SU"
            }, {
                "text": "Yogyakarta",
                "value": "YO"
            }]
        }

        # to convert python structure same as json output
        expected_state_list_id = tu.convert_py_json_output(expected_state_list)

        state_list = json.dumps({"states_list": "id"})

        state_list_id = tu.send_and_receive_ws_x_authorize(state_list)

        self.assertTrue(tu.compare_data(state_list_id, expected_state_list_id))
        self.assertTrue('error' not in state_list_id)