def test_group_delete_if_exists(group_1: Group): # check when there is no group assert Group.delete_if_exists(urlname=group_1.urlname) is False # save group group_1.save() sleep(1) # delete group assert Group.delete_if_exists(urlname=group_1.urlname) is True sleep(1) # check if group is really deleted with pytest.raises(GroupDoesNotExists): Group.get_group(urlname=group_1.urlname)
def get_group(self, group_urlname: str) -> Group: """ get or create a Group based on the group_urlname and fill / update the object from meetup rest api Arguments: group_urlname {str} -- Meetup group the urlname as string Raises: GroupDoesNotExistsOnMeetup: Group does not exists on Meetup.com MeetupConnectionError: Some network error to meetup.com Returns: Group -- Group based on the group_urlname """ try: response: dict = self.get("{}".format(group_urlname)) except (HttpNotAccessibleError, HttpNotFoundError): # delete group if exists Group.delete_if_exists(urlname=group_urlname) raise GroupDoesNotExistsOnMeetup( "{} group does not exists on meetup.com!".format( group_urlname)) except (HttpNoXRateLimitHeader): raise MeetupConnectionError( "Could not connect to meetup -> Rate Limits reached for {}!". format(group_urlname)) except (HttpNoSuccess): raise MeetupConnectionError( "Could not connect to meetup -> network problems for {}". format(group_urlname)) group: Group = get_group_from_response(response=response) group.save() return group