def test_get_list(self): self.assertListEqual(['../DataFolder\\mogoroom-bs.csv', '../DataFolder\\mogoroom-partner.csv', '../DataFolder\\mogoroom-renter.csv', '../DataFolder\\mogoroom-test.csv'],DataMapper._get_file_list(None)) self.prop.set('test.fileformat','.txt') self.assertListEqual(['../DataFolder\\derset.txt'],DataMapper._get_file_list(None)) self.prop.set('test.fileformat','.csv') self.assertListEqual(['../DataFolder/mogoroom-bs.csv'],DataMapper._get_file_list(['mogoroom-bs.csv'])) self.assertListEqual([],DataMapper._get_file_list(['mogoroombs.csv']))
def test_filter(self): datamapper=DataMapper.dataProvider('../DataFolder\\mogoroom-test.csv') dict_content=datamapper.dict_content self.assertEqual(103,len(dict_content)) mogo_test_filter=DataMapper.Filter(dict_content) self.assertEqual(89,len(mogo_test_filter.filterBy(case_status='active'))) self.assertEqual(0,len(mogo_test_filter.filterBy(case_status=''))) self.assertEqual(14,len(mogo_test_filter.filterBy(case_status='skip')))
def test_dataprovider(self): datamapper=DataMapper.dataProvider(path='../DataFolder/mogoroom-bs.csv') self.assertEqual('mogoroom-bs',datamapper.name) self.assertListEqual(['case_id', 'requestPath', 'requestParameters', 'requestBody', 'requestHeader', 'requestMethod', 'response_status', 'response_body', 'sql_validation', 'case_status', 'needUserToken', 'depandent', 'group', 'feature', 'priority', 'comment'],datamapper.header) self.assertEqual(0,len(datamapper.header_check())) with open('../DataFolder/mogoroom-bs.csv',mode='r',encoding='gbk') as f: reader=csv.reader(f) expected=[row for row in reader] self.assertListEqual(expected,datamapper.content) self.assertEqual(52,len(datamapper.dict_content))
def test_dataprovider_neg(self): datamapper=DataMapper.dataProvider('../DataFolder\\mogoroom-test.csv') self.assertEqual(106,len(datamapper.content)) self.assertEqual(103,len(datamapper.dict_content))