def test_net(self):
     csvfile = open('/home/clyde/lot18/net_test.csv')
     v = Validator(csvfile)
     v.validators = ['ny_net']
     v.prohibited_states = prohibited_states
     r = v()
     csvfile.close()
     self.assertTrue([i['valid'] for i in r][0])
 def test_email(self):
     csvfile = open('/home/clyde/lot18/email_test.csv')
     v = Validator(csvfile)
     v.validators = ['email']
     v.prohibited_states = prohibited_states
     r = v()
     csvfile.close()
     self.assertEqual([False,True,False], [i['valid'] for i in r])
Example #3
0
def import_orders():
    if request.method == 'GET':
        return render_template('import_orders.html')
    if request.method == 'POST' and request.files['file']:
        orders = request.files['file']
        if not orders.filename.endswith('.csv'):
            return 'Please select a valid csv file'
        v = Validator(orders)
        v.prohibited_states = prohibited_states
        v.validators = validators
        validated_records = v()
        result = save2mongo(validated_records)
        if result:
            return 'your orders have been succesfully posted'
        elif not result:
            return 'there has been a problem uploading your order'
    else:
        return  render_template('import_orders.html')