def short_url_single_view(short_url): return { 'url': short_url.url, 'short_url': make_uri(short_url.sid), 'created': short_url.created_at, 'clicks': short_url.visited_counter }
def it_should_return_an_sid(self): expect(self.result).to( equal({ 'success': True, 'short_url': make_uri(self.short_url), 'url': self.url }))
def the_second_request_it_should_return_an_error(self): expect(self.result).to(equal({ 'success': False, 'short_message': "Short URL is not available.", 'error_message': "The url {} is not available. Try another one.".format(make_uri(self.short_url)), 'short_url': self.short_url, 'url': self.url }))
def short_it_collision_view(url, sid): return { 'success': False, 'short_message': "Short URL is not available.", 'error_message': "The url {} is not available. Try another one.".format(make_uri(sid)), 'short_url': sid, 'url': url }
def given_a_short_url_that_is_already_created(self): self.url = "http://www.domain.com/big-article-name-with-params/?q=qwerty&t=10" self.sid = shortifier(self.url) self.short_url = make_uri(self.sid) make_short_it_request({ "url": self.url, "short_url": self.sid })
def make_user_urls_request(token, sid=''): headers = {'Content-type': 'application/json', 'Authorization': token} result = requests.get( make_uri("short_urls/{}".format(sid)), headers=headers ) return result.json(), result.status_code
def make_short_it_request(data): """Make a request on the short_it endpoint. Pass Authorization token from the user that already exists in db""" data_json = json.dumps(data) headers = {'Content-type': 'application/json', 'Authorization': 'NyaWDJekdjWI38KejJWlkd93jsdtu'} result = requests.post( make_uri("short_it/"), data=data_json, headers=headers ) return result.json(), result.status_code
def the_second_request_it_should_return_an_error(self): expect(self.result).to( equal({ 'success': False, 'short_message': "Short URL is not available.", 'error_message': "The url {} is not available. Try another one.".format( make_uri(self.short_url)), 'short_url': self.short_url, 'url': self.url }))
def it_should_return_an_sid(self): expect(self.result).to(equal({ 'success': True, 'short_url': make_uri(self.short_url), 'url': self.url }))
def short_it_success_view(url, sid): return {'success': True, 'short_url': make_uri(sid), 'url': url}
def given_a_short_url_that_is_already_created(self): self.short_url = make_uri(shortifier(''))
def short_it_success_view(url, sid): return { 'success': True, 'short_url': make_uri(sid), 'url': url }
def given_a_short_url_that_is_already_created(self): self.url = "http://www.domain.com/big-article-name-with-params/?q=qwerty&t=10" self.sid = shortifier(self.url) self.short_url = make_uri(self.sid) make_short_it_request({"url": self.url, "short_url": self.sid})