def add_marriage_in_geni(self, union=None): ''' This method add marriage data in geni, add union if there is no unique marriage ''' if (union is None): #If no union is added is because is the unique... if (len(self.marriage_union) == 1): union = self.marriage_union[0].union_id else: #If we have more than one marriage we cannot proceed return False #We create the url for creating the child update_marriage = s.GENI_API + union + s.GENI_UPDATE + s.GENI_INITIATE_PARAMETER + s.GENI_TOKEN + s.get_token( ) #We add the event data for marriage data_input = {} event_obtained = event_value(self, "marriage") if (event_obtained): data_input["marriage"] = event_obtained #We also add the needed data, that we take from the base profile directly r = s.geni_request_post(update_marriage, data_input=data_input) data = r.json() if "error" in data.keys(): logging.error(ERROR_REQUESTS + str(data["error"])) return False #TODO: process the data creation and update relations return True
def test_error_get_post(self): ''' Test error get and post ''' data = geni_request_get(GENI_WRONG_GET_METHOD) assert ("error" in data.json()) data2 = geni_request_post(GENI_WRONG_GET_METHOD) assert ("error" in data2.json())
def delete_profile(self): ''' We delete this profile from Geni ''' url_delete = s.GENI_PROFILE + self.geni_specific_data['id'] + s.GENI_DELETE + self.token_string() r = s.geni_request_post(url_delete) self.data = r.json() if ( self.data.get("result", None) == "Deleted"): self.existing_in_geni = False #Essentially, we delete all GENI data self.geni_specific_data = {} return True else: return False
def creation_operations(self, adding_input, data_input): ''' Common functions on creating profiles ''' #Some checking parameters initiated self.properly_executed = False self.existing_in_geni = False self.data = {} self.geni_specific_data = {} #We also add the needed data, that we take from the base profile directly r = s.geni_request_post(adding_input, data_input=data_input) data = r.json() if "error" not in data.keys(): self.data = data self.properly_executed = True self.existing_in_geni = True self.id = stripId(data["id"]) self.guid = int(data["guid"]) self.get_geni_data(data)