예제 #1
0
    def test_incorrect_host_delete_dataset(self):
        """The method is negative test on delete dataset with incorrect host"""

        with self.assertRaises(ValueError) as context:
            apicfg = knoema.ApiConfig()
            apicfg.host = 'knoema_incorect.com'
            knoema.delete('dataset')
        self.assertTrue("The specified host knoema_incorect.com does not exist" in str(context.exception))
예제 #2
0
    def test_incorrect_host_verify_dataset(self):
        """The method is negative test on verify dataset with incorrect host"""

        with self.assertRaises(ValueError) as context:
            apicfg = knoema.ApiConfig()
            apicfg.host = 'knoema_incorect.com'
            knoema.verify('non_existing_id', datetime.date.today(), 'IMF', 'http://knoema.com')
        self.assertTrue("The specified host knoema_incorect.com does not exist" in str(context.exception))    
예제 #3
0
    def test_incorrect_host_knoema_get(self):
        """The method is negative test on get series from dataset with incorrect host"""

        with self.assertRaises(ValueError) as context:
            apicfg = knoema.ApiConfig()
            apicfg.host = 'knoema_incorect.com'
            data_frame = knoema.get('IMFWEO2017Apr', country='914', subject='ngdp')
        self.assertTrue("The specified host knoema_incorect.com does not exist" in str(context.exception))
예제 #4
0
    def test_getdata_from_private_community(self):
        """The method is testing getting data from private community"""

        apicfgCommunity = knoema.ApiConfig()
        apicfgCommunity.host = 'teryllol.' + self.base_host
        apicfgCommunity.app_id = 's81oiSY'
        apicfgCommunity.app_secret='g4lKmIOPE2R4w'

        data_frame = knoema.get('qfsneof', country='USA', series='NY.GDP.MKTP.KD.ZG')
        self.assertEqual(data_frame.shape[0], 58)
        self.assertEqual(data_frame.shape[1], 1)

        self.assertEqual(['Country', 'Series', 'Frequency'], data_frame.columns.names)

        indx = data_frame.first_valid_index()
        sname = ('United States', 'GDP growth (annual %)', 'A')
        value = data_frame.get_value(indx, sname)
        self.assertEqual(value, 2.29999999999968)

        indx = data_frame.index[57]
        value = data_frame.get_value(indx, sname)
        self.assertEqual(value, 2.92732272821085)
예제 #5
0
 def setUp(self):
     apicfg = knoema.ApiConfig()
     apicfg.host = 'knoema.org'
     apicfg.app_id = 'FzOYqDg'
     apicfg.app_secret='SPrvmY8eGRcGA'
예제 #6
0
import knoema
import pandas as pd

apicfg = knoema.ApiConfig()

data_frame = knoema.get(
    'JODIOIL2018',
    timerange='2019M4-2020M3',
    frequency='M',
    Country=
    'CD;CG;RW;GH;DZ;ZA;LY;EG;GN;LS;AO;CF;SO;BF;GA;TG;SL;LR;DJ;ER;KE;GM;KM;CV;CI;CM;ET;BI;ML;TD;BJ;SZ;GQ;ZW;SD;MW;MZ;NE;GW;TZ;SN;UG;ZM;SS;MG;MU;SC;TN;BW;NG;MA;ST;MR;NA;KZ;JP;MN;PK;AM;BD;LK;AF;BT;TJ;IN;TM;GE;KG;UZ;AZ;KP;MV;KR;NP;CN;AG;BB;DM;GD;KN;LC;VC;CU;GT;DO;JM;CR;PA;HN;NI;BZ;SV;TT;BS;HT;PR;AD;CH;FR;LU;MC;MT;SM;BY;IT;ES;NL;PL;BE;BG;HU;SE;CZ;DK;PT;RO;AT;GR;SK;EE;IE;LT;LV;NO;RU;HR;UA;MD;MK;AL;ME;BA;RS;IS;FI;GB;SI;LI;DE;CA;MX;US;FM;KI;MH;NR;PW;TO;TV;VU;WS;AU;NZ;PG;SB;FJ;HK;MO;TW;PH;MY;TH;SG;VN;LA;MM;TL;BN;KH;ID;VE;BR;AR;CL;CO;PE;EC;PY;UY;BO;GY;SR;CY;TR;BH;YE;KW;OM;QA;IQ;IR;AE;IL;SY;JO;LB;PS;SA',
    Flow='P.INDPROD',
    Product='CRUDEOIL',
    Measure='KBD')

data_frame = knoema.knoema.get()
def get_client():
    apicfg = knoema.ApiConfig()
    apicfg.host = base_host
    apicfg.app_id = os.environ['KNOEMA_APP_ID'] if 'KNOEMA_APP_ID' in os.environ else 'DguAM8'
    apicfg.app_secret = os.environ['KNOEMA_APP_SECRET'] if 'KNOEMA_APP_SECRET' in os.environ else 'Io0OgIy1TNwtAA'