def setup(self): #use testing config self.conf = config.TestingConfig() server_settings = self.conf.get_server_config() self.username = str(server_settings['username']) self.password = str(server_settings['password']) self.url = str(server_settings['url']) self.flexipy = Flexipy(self.conf) self.faktura = Faktura(self.conf) #create some items in flexibee self.faktura.create_vydana_faktura(kod='flex11', var_sym='11235484', datum_vyst='2013-02-28', zdroj_pro_sklad=False) dalsiParams = {'specSym': 48152342} #tyto dve jsou pro testovani get all records self.faktura.create_vydana_faktura(kod='flex12', var_sym='11235494', datum_vyst='2013-03-14', zdroj_pro_sklad=False, dalsi_param=dalsiParams) self.faktura.create_vydana_faktura(kod='flex13', var_sym='11235495', datum_vyst='2013-02-17', zdroj_pro_sklad=False, dalsi_param=dalsiParams)
def setup(self): self.conf = config.TestingConfig() server_settings = self.conf.get_server_config() self.username = str(server_settings['username']) self.password = str(server_settings['password']) self.url = str(server_settings['url']) self.faktura = Faktura(self.conf)
def setup(self): #use testing config self.conf = config.TestingConfig() server_settings = self.conf.get_server_config() self.username = str(server_settings['username']) self.password = str(server_settings['password']) self.url = str(server_settings['url']) self.flexipy = Flexipy(self.conf) self.faktura = Faktura(self.conf) #create some items in flexibee self.faktura.create_vydana_faktura(kod='flex11', var_sym='11235484', datum_vyst='2013-02-28', zdroj_pro_sklad=False) dalsiParams = {'specSym':48152342} #tyto dve jsou pro testovani get all records self.faktura.create_vydana_faktura(kod='flex12', var_sym='11235494', datum_vyst='2013-03-14', zdroj_pro_sklad=False,dalsi_param=dalsiParams) self.faktura.create_vydana_faktura(kod='flex13', var_sym='11235495', datum_vyst='2013-02-17', zdroj_pro_sklad=False,dalsi_param=dalsiParams)
class TestFaktura: def setup(self): self.conf = config.TestingConfig() server_settings = self.conf.get_server_config() self.username = str(server_settings['username']) self.password = str(server_settings['password']) self.url = str(server_settings['url']) self.faktura = Faktura(self.conf) def test_get_all_vydane_faktury(self): r = requests.get(self.url + 'faktura-vydana.json', auth=(self.username, self.password), verify=False) d = r.json() if len(d['winstrom']['faktura-vydana']): list_of_invoices_expected = d['winstrom']['faktura-vydana'][0] else: list_of_invoices_expected = d['winstrom']['faktura-vydana'] list_of_invoices_actual = self.faktura.get_all_vydane_faktury() assert list_of_invoices_expected == list_of_invoices_actual def test_get_all_prijate_faktury(self): r = requests.get(self.url + 'faktura-prijata.json', auth=(self.username, self.password), verify=False) d = r.json() if (len(d['winstrom']['faktura-prijata']) == 1): list_of_invoices_expected = d['winstrom']['faktura-prijata'][0] else: list_of_invoices_expected = d['winstrom']['faktura-prijata'] list_of_invoices_actual = self.faktura.get_all_prijate_faktury() assert list_of_invoices_expected == list_of_invoices_actual def test_create_vydana_faktura(self): expected_data = { 'kod': 'flex11', 'typDokl': 'code:FAKTURA', 'firma': 'code:201', 'popis': 'Flexipy test invoice', 'sumDphZakl': '0.0', 'bezPolozek': 'true', 'varSym': '11235484', 'zdrojProSkl': 'false' } dalsi_param = {'popis': 'Flexipy test invoice', 'firma': 'code:201'} result = self.faktura.create_vydana_faktura( kod='flex11', var_sym='11235484', datum_vyst='2013-02-28', zdroj_pro_sklad=False, typ_dokl=self.conf.get_typy_faktury_vydane()[0], dalsi_param=dalsi_param) assert result[0] == True #expected True id = result[1] actualData = self.faktura.get_vydana_faktura(id, detail='full') assert actualData['kod'].lower() == expected_data['kod'].lower() assert actualData['typDokl'] == expected_data['typDokl'] assert actualData['firma'] == expected_data['firma'] assert actualData['popis'] == expected_data['popis'] assert actualData['sumDphZakl'] == expected_data['sumDphZakl'] #uklid po sobe self.faktura.delete_vydana_faktura(id) def test_create_vydana_faktura_polozky(self): polozky = [{ 'typPolozkyK': self.conf.get_typ_polozky_vydane()[0], 'zdrojProSkl': False, 'nazev': 'vypujceni auta', 'ucetni': True, 'cenaMj': '4815.0' }] expected_data = { 'kod': 'flex12', 'typDokl': 'code:FAKTURA', 'firma': 'code:201', 'popis': 'Flexipy test invoice', 'varSym': '11235484', 'zdrojProSkl': 'false', 'polozkyFaktury': polozky } expected_polozky = [{ 'typPolozkyK': 'typPolozky.obecny', 'zdrojProSkl': 'false', 'nazev': 'vypujceni auta', 'ucetni': 'true', 'cenaMj': '4815.0' }] dalsi_param = { 'popis': 'Flexipy test invoice', 'firma': 'code:201', 'typUcOp': u'code:TRŽBA SLUŽBY' } result = self.faktura.create_vydana_faktura( kod='flex12', var_sym='11235484', datum_vyst='2013-02-28', zdroj_pro_sklad=False, typ_dokl=self.conf.get_typy_faktury_vydane()[0], dalsi_param=dalsi_param, polozky_faktury=polozky) assert result[0] == True #expected True id = result[1] actualData = self.faktura.get_vydana_faktura(id, detail='full') assert actualData['kod'].lower() == expected_data['kod'].lower() assert actualData['typDokl'] == expected_data['typDokl'] assert actualData['firma'] == expected_data['firma'] assert actualData['popis'] == expected_data['popis'] #pocet polozek se musi rovnat assert len(actualData['polozkyFaktury']) == len(expected_polozky) actual_polozky = actualData['polozkyFaktury'][0] assert actual_polozky['typPolozkyK'] == expected_polozky[0][ 'typPolozkyK'] assert actual_polozky['nazev'] == expected_polozky[0]['nazev'] assert actual_polozky['cenaMj'] == expected_polozky[0]['cenaMj'] #uklid po sobe self.faktura.delete_vydana_faktura(id)
class TestFaktura: def setup(self): self.conf = config.TestingConfig() server_settings = self.conf.get_server_config() self.username = str(server_settings['username']) self.password = str(server_settings['password']) self.url = str(server_settings['url']) self.faktura = Faktura(self.conf) def test_get_all_vydane_faktury(self): r = requests.get(self.url+'faktura-vydana.json' ,auth=(self.username,self.password), verify=False) d = r.json() if len(d['winstrom']['faktura-vydana']): list_of_invoices_expected = d['winstrom']['faktura-vydana'][0] else: list_of_invoices_expected = d['winstrom']['faktura-vydana'] list_of_invoices_actual = self.faktura.get_all_vydane_faktury() assert list_of_invoices_expected == list_of_invoices_actual def test_get_all_prijate_faktury(self): r = requests.get(self.url+'faktura-prijata.json' ,auth=(self.username,self.password), verify=False) d = r.json() if(len(d['winstrom']['faktura-prijata']) == 1): list_of_invoices_expected = d['winstrom']['faktura-prijata'][0] else: list_of_invoices_expected = d['winstrom']['faktura-prijata'] list_of_invoices_actual = self.faktura.get_all_prijate_faktury() assert list_of_invoices_expected == list_of_invoices_actual def test_create_vydana_faktura(self): expected_data = {'kod':'flex11','typDokl':'code:FAKTURA','firma':'code:201','popis':'Flexipy test invoice', 'sumDphZakl':'0.0','bezPolozek':'true', 'varSym':'11235484','zdrojProSkl':'false'} dalsi_param = {'popis':'Flexipy test invoice','firma':'code:201'} result = self.faktura.create_vydana_faktura(kod='flex11', var_sym='11235484', datum_vyst='2013-02-28', zdroj_pro_sklad=False, typ_dokl=self.conf.get_typy_faktury_vydane()[0], dalsi_param=dalsi_param) assert result[0] == True #expected True id = result[1] actualData = self.faktura.get_vydana_faktura(id, detail='full') assert actualData['kod'].lower() == expected_data['kod'].lower() assert actualData['typDokl'] == expected_data['typDokl'] assert actualData['firma'] == expected_data['firma'] assert actualData['popis'] == expected_data['popis'] assert actualData['sumDphZakl'] == expected_data['sumDphZakl'] #uklid po sobe self.faktura.delete_vydana_faktura(id) def test_create_vydana_faktura_polozky(self): polozky = [{'typPolozkyK':self.conf.get_typ_polozky_vydane()[0],'zdrojProSkl':False,'nazev':'vypujceni auta','ucetni':True,'cenaMj':'4815.0'}] expected_data = {'kod':'flex12','typDokl':'code:FAKTURA','firma':'code:201','popis':'Flexipy test invoice', 'varSym':'11235484','zdrojProSkl':'false','polozkyFaktury':polozky} expected_polozky = [{'typPolozkyK':'typPolozky.obecny','zdrojProSkl':'false','nazev':'vypujceni auta','ucetni':'true','cenaMj':'4815.0'}] dalsi_param = {'popis':'Flexipy test invoice','firma':'code:201','typUcOp':u'code:TRŽBA SLUŽBY'} result = self.faktura.create_vydana_faktura(kod='flex12', var_sym='11235484', datum_vyst='2013-02-28', zdroj_pro_sklad=False, typ_dokl=self.conf.get_typy_faktury_vydane()[0], dalsi_param=dalsi_param, polozky_faktury=polozky) assert result[0] == True #expected True id = result[1] actualData = self.faktura.get_vydana_faktura(id, detail='full') assert actualData['kod'].lower() == expected_data['kod'].lower() assert actualData['typDokl'] == expected_data['typDokl'] assert actualData['firma'] == expected_data['firma'] assert actualData['popis'] == expected_data['popis'] #pocet polozek se musi rovnat assert len(actualData['polozkyFaktury']) == len(expected_polozky) actual_polozky = actualData['polozkyFaktury'][0] assert actual_polozky['typPolozkyK'] == expected_polozky[0]['typPolozkyK'] assert actual_polozky['nazev'] == expected_polozky[0]['nazev'] assert actual_polozky['cenaMj'] == expected_polozky[0]['cenaMj'] #uklid po sobe self.faktura.delete_vydana_faktura(id)
def __init__(self, faktura=Faktura()): self.faktura = faktura
class TestFlexipy: def setup(self): #use testing config self.conf = config.TestingConfig() server_settings = self.conf.get_server_config() self.username = str(server_settings['username']) self.password = str(server_settings['password']) self.url = str(server_settings['url']) self.flexipy = Flexipy(self.conf) self.faktura = Faktura(self.conf) #create some items in flexibee self.faktura.create_vydana_faktura(kod='flex11', var_sym='11235484', datum_vyst='2013-02-28', zdroj_pro_sklad=False) dalsiParams = {'specSym':48152342} #tyto dve jsou pro testovani get all records self.faktura.create_vydana_faktura(kod='flex12', var_sym='11235494', datum_vyst='2013-03-14', zdroj_pro_sklad=False,dalsi_param=dalsiParams) self.faktura.create_vydana_faktura(kod='flex13', var_sym='11235495', datum_vyst='2013-02-17', zdroj_pro_sklad=False,dalsi_param=dalsiParams) def teardown(self): inv1 = self.faktura.get_vydana_faktura_by_code('flex11') inv2 = self.faktura.get_vydana_faktura_by_code('flex12') inv3 = self.faktura.get_vydana_faktura_by_code('flex13') self.faktura.delete_vydana_faktura(inv1['id']) self.faktura.delete_vydana_faktura(inv2['id']) self.faktura.delete_vydana_faktura(inv3['id']) def test_validate_item(self): invalid_params = {'doprava':'','duzpaPuv':'','zaveTxt':''} pytest.raises(FlexipyException,self.flexipy.validate_params, invalid_params, 'faktura-vydana') def test_get_template_dict(self): expected_result = {u'kod': '', u'nazev': ''} assert expected_result == self.flexipy.get_template_dict('adresar') def test_send_request(self): expected_resp = requests.get(url=self.url+'faktura-vydana.json',auth=(self.username,self.password),verify=False) actual_resp = self.flexipy.send_request(method='get', endUrl='faktura-vydana.json') assert expected_resp.status_code == actual_resp.status_code assert expected_resp.json() == actual_resp.json() def test_prepare_date(self): data = {'kod':'inv1','nazev':'mojeFaktura'} expected_result = json.dumps({'winstrom':{'faktura-vydana':[data]}}) actual_result = self.flexipy.prepare_data('faktura-vydana', data) assert expected_result == actual_result def test_get_all_records_without_query(self): r = requests.get(self.url+'faktura-vydana.json',auth=(self.username,self.password),verify=False) expected_result = r.json()['winstrom']['faktura-vydana'] actual_result = self.flexipy.get_all_records('faktura-vydana') assert expected_result == actual_result def test_get_all_records_with_query(self): #get all records with specSym = 48152342 url = self.url+'faktura-vydana/(specSym="48152342").json' r = requests.get(url=url,auth=(self.username,self.password),verify=False) expected_result = r.json()['winstrom']['faktura-vydana'] actual_result = self.flexipy.get_all_records('faktura-vydana',query="specSym='"+str(48152342)+"'") assert len(expected_result) == len(actual_result) assert expected_result == actual_result def test_get_evidence_property_list(self): pass
class TestFlexipy: def setup(self): #use testing config self.conf = config.TestingConfig() server_settings = self.conf.get_server_config() self.username = str(server_settings['username']) self.password = str(server_settings['password']) self.url = str(server_settings['url']) self.flexipy = Flexipy(self.conf) self.faktura = Faktura(self.conf) #create some items in flexibee self.faktura.create_vydana_faktura(kod='flex11', var_sym='11235484', datum_vyst='2013-02-28', zdroj_pro_sklad=False) dalsiParams = {'specSym': 48152342} #tyto dve jsou pro testovani get all records self.faktura.create_vydana_faktura(kod='flex12', var_sym='11235494', datum_vyst='2013-03-14', zdroj_pro_sklad=False, dalsi_param=dalsiParams) self.faktura.create_vydana_faktura(kod='flex13', var_sym='11235495', datum_vyst='2013-02-17', zdroj_pro_sklad=False, dalsi_param=dalsiParams) def teardown(self): inv1 = self.faktura.get_vydana_faktura_by_code('flex11') inv2 = self.faktura.get_vydana_faktura_by_code('flex12') inv3 = self.faktura.get_vydana_faktura_by_code('flex13') self.faktura.delete_vydana_faktura(inv1['id']) self.faktura.delete_vydana_faktura(inv2['id']) self.faktura.delete_vydana_faktura(inv3['id']) def test_validate_item(self): invalid_params = {'doprava': '', 'duzpaPuv': '', 'zaveTxt': ''} pytest.raises(FlexipyException, self.flexipy.validate_params, invalid_params, 'faktura-vydana') def test_get_template_dict(self): expected_result = {u'kod': '', u'nazev': ''} assert expected_result == self.flexipy.get_template_dict('adresar') def test_send_request(self): expected_resp = requests.get(url=self.url + 'faktura-vydana.json', auth=(self.username, self.password), verify=False) actual_resp = self.flexipy.send_request(method='get', endUrl='faktura-vydana.json') assert expected_resp.status_code == actual_resp.status_code assert expected_resp.json() == actual_resp.json() def test_prepare_date(self): data = {'kod': 'inv1', 'nazev': 'mojeFaktura'} expected_result = json.dumps({'winstrom': {'faktura-vydana': [data]}}) actual_result = self.flexipy.prepare_data('faktura-vydana', data) assert expected_result == actual_result def test_get_all_records_without_query(self): r = requests.get(self.url + 'faktura-vydana.json', auth=(self.username, self.password), verify=False) expected_result = r.json()['winstrom']['faktura-vydana'] actual_result = self.flexipy.get_all_records('faktura-vydana') assert expected_result == actual_result def test_get_all_records_with_query(self): #get all records with specSym = 48152342 url = self.url + 'faktura-vydana/(specSym="48152342").json' r = requests.get(url=url, auth=(self.username, self.password), verify=False) expected_result = r.json()['winstrom']['faktura-vydana'] actual_result = self.flexipy.get_all_records('faktura-vydana', query="specSym='" + str(48152342) + "'") assert len(expected_result) == len(actual_result) assert expected_result == actual_result def test_get_evidence_property_list(self): pass