def updateQhawaxInstallation():
    """Updates qHAWAX in Field"""
    data_json = request.get_json()
    description = "Some fields of qHAWAX installation were updated"
    try:
        qH_name, in_charge = exception_helper.getInstallationFields(data_json)
        post_business_helper.updateQhawaxInstallation(data_json)
        post_business_helper.writeBinnacle(qH_name, description, in_charge)
        return make_response(
            {"Sucess": "qHAWAX field information have been updated"}, 200)
    except TypeError as e:
        json_message = jsonify({"error": "'%s'" % (e)})
        return make_response(json_message, 400)
Ejemplo n.º 2
0
 def test_update_qhawax_installation_valid(self):
     installation_json = {
         'lat': '-12.0000499',
         'lon': '-77.9000000',
         'comercial_name': 'Unit Test Coveralls',
         'company_id': 1,
         'eca_noise_id': 1,
         'qhawax_id': 15,
         'connection_type': 'Panel Solar',
         'season': 'Primavera',
         'is_public': 'no',
         'person_in_charge': 'l.montalvo'
     }
     post_business_helper.updateQhawaxInstallation(installation_json)
 def test_create_qhawax_and_default_sensors_valid(self):
     installation_date = "2020-12-29 00:44:00.0-05:00"
     end_date_string = "2020-12-29 01:00:00.255258"
     person_in_charge = "l.montalvo"
     qhawax_name = "qH102"
     post_business_helper.createQhawax(qhawax_name, "STATIC")
     installation_json = {
         "lat": "-7.0000499",
         "lon": "-70.9000000",
         "comercial_name": "Unit Test "
         + str(randint(0, 30))
         + " Coveralls",
         "company_id": 1,
         "eca_noise_id": 1,
         "qhawax_name": qhawax_name,
         "connection_type": "Panel Solar",
         "season": "Primavera",
         "is_public": "no",
         "person_in_charge": person_in_charge,
         "instalation_date": installation_date,
         "link_report": "Test",
         "observations": "Test Obs",
         "district": "La Victoria",
     }
     post_business_helper.storeNewQhawaxInstallation(installation_json)
     description = "qHAWAX record in field"
     post_business_helper.writeBinnacle(
         qhawax_name, description, person_in_charge
     )
     installation_json_update = {
         "lat": "-12.0000499",
         "lon": "-77.9000000",
         "comercial_name": "Unit Test Coveralls " + str(randint(0, 30)),
         "company_id": 1,
         "eca_noise_id": 1,
         "qhawax_name": qhawax_name,
         "connection_type": "Panel Solar",
         "season": "Primavera",
         "is_public": "no",
         "person_in_charge": "l.montalvo",
     }
     post_business_helper.updateQhawaxInstallation(installation_json_update)
     post_business_helper.saveEndWorkFieldDate(qhawax_name, end_date_string)
     description = "qHAWAX save end work in field"
     post_business_helper.writeBinnacle(
         qhawax_name, description, person_in_charge
     )
def updateQhawaxInstallation():
    """
    To create a qHAWAX in Field 

    """
    try:
        data_json = request.get_json()
        qhawax_id = int(data_json['qhawax_id'])
        description = int(data_json['description'])
        person_in_charge = data_json['person_in_charge']
        post_business_helper.updateQhawaxInstallation(data_json)
        qhawax_name = same_helper.getQhawaxName(qhawax_id)
        helper.writeBitacora(qhawax_name, description, person_in_charge)
    except TypeError as e:
        json_message = jsonify({'error': '\'%s\'' % (e)})
        return make_response(json_message, 400)
    else:
        return make_response({'Sucess': 'Update data of qHAWAX in field'}, 200)
	def test_create_qhawax_and_default_sensors_valid(self):
		installation_date = "2020-12-29 00:44:00.0-05:00"
		end_date_string = "2020-12-29 01:00:00.255258"
		person_in_charge = 'l.montalvo'
		qhawax_name = 'qH102'
		post_business_helper.createQhawax(qhawax_name,'STATIC')
		installation_json = {'lat':'-7.0000499','lon':'-70.9000000',
							 'comercial_name':'Unit Test '+str(randint(0, 30))+' Coveralls',
							 'company_id':1,'eca_noise_id':1,'qhawax_name':qhawax_name,
							 'connection_type':'Panel Solar','season':'Primavera','is_public':'no',
							 'person_in_charge':person_in_charge,"instalation_date":installation_date,
							 'link_report':'Test','observations':'Test Obs','district':"La Victoria"}
		post_business_helper.storeNewQhawaxInstallation(installation_json)
		description = 'qHAWAX record in field'
		post_business_helper.writeBinnacle(qhawax_name,description,person_in_charge)
		installation_json_update = {'lat':'-12.0000499','lon':'-77.9000000','comercial_name':'Unit Test Coveralls '+str(randint(0, 30)),
							 		'company_id':1,'eca_noise_id':1,'qhawax_name':qhawax_name,'connection_type':'Panel Solar',
							 		'season':'Primavera','is_public':'no','person_in_charge':'l.montalvo'}
		post_business_helper.updateQhawaxInstallation(installation_json_update)
		post_business_helper.saveEndWorkFieldDate(qhawax_name,end_date_string)
		description = 'qHAWAX save end work in field'
		post_business_helper.writeBinnacle(qhawax_name,description,person_in_charge)