def test_find_closest_store_units_km_negative(self): dict_list=data.get_data_from_csv('store-locations.csv') val='1455 Market St, San Francisco, CA 94103' units,output,addr_zip='km','json','address' output=data.find_closest_store(dict_list,val,units,output,addr_zip) try: result=json.loads(output) result=result['Distance'] except ValueError as error: result=0.0 expected=1.614 self.assertNotEqual(expected,result)
def test_find_closest_store_output_zip_code_positive(self): dict_list=data.get_data_from_csv('store-locations.csv') val='93065' units,output,addr_zip='mi','json','zipcode' output=data.find_closest_store(dict_list,val,units,output,addr_zip) try: result=json.loads(output) result=result['Store_Name'] except: result='Error' expected='Simi Valley West' self.assertEqual(expected,result)
def test_find_closest_store_output_negative(self): dict_list=result=data.get_data_from_csv('store-locations.csv') val='1455 Market St, San Francisco, CA 94103' units,output,addr_zip='mi','text','address' output=data.find_closest_store(dict_list,val,units,output,addr_zip) try: json.loads(output) result=True except ValueError as error: result=False expected=False self.assertEqual(expected,result)
def test_find_closest_store_output_address_positive(self): dict_list=data.get_data_from_csv('store-locations.csv') val='1455 Market St, San Francisco, CA 94103' units,output,addr_zip='mi','json','address' output=data.find_closest_store(dict_list,val,units,output,addr_zip) try: result=json.loads(output) result=result['Store_Name'] except: result='Error' expected='San Francisco Central' self.assertEqual(expected,result)
if not dict_list: raise TypeError except: print( 'No data found in the csv file / docopt unable to parse the arguments in the cli command' ) try: if arguments['--address'] != None: address = arguments['--address'] units = 'mi' if arguments['--units'] is None else arguments[ '--units'] # check this output = 'text' if arguments['--output'] is None else arguments[ '--output'] print( data.find_closest_store(dict_list, address, units, output, 'address')) elif arguments['--zip'] != None: zip_code = arguments['--zip'] units = 'mi' if arguments['--units'] is None else arguments[ '--units'] # check this output = 'text' if arguments['--output'] is None else arguments[ '--output'] res = data.find_closest_store(dict_list, zip_code, units, output, 'zipcode') print(res) else: print('Invalid Input. Please try again') except: print('Invalid data . Please try again')