Example #1
0
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
    }
Example #2
0
 def it_should_return_an_sid(self):
     expect(self.result).to(
         equal({
             'success': True,
             'short_url': make_uri(self.short_url),
             'url': self.url
         }))
Example #3
0
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
    }
Example #4
0
 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
     }))
Example #5
0
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
    }
Example #6
0
    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
        })
Example #7
0
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
Example #8
0
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
    }
Example #9
0
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
Example #10
0
 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
         }))
Example #11
0
 def it_should_return_an_sid(self):
     expect(self.result).to(equal({
         'success': True,
         'short_url': make_uri(self.short_url),
         'url': self.url
     }))
Example #12
0
def short_it_success_view(url, sid):
    return {'success': True, 'short_url': make_uri(sid), 'url': url}
Example #13
0
 def given_a_short_url_that_is_already_created(self):
     self.short_url = make_uri(shortifier(''))
Example #14
0
def short_it_success_view(url, sid):
    return {
        'success': True,
        'short_url': make_uri(sid),
        'url': url
    }
Example #15
0
 def given_a_short_url_that_is_already_created(self):
     self.short_url = make_uri(shortifier(''))
Example #16
0
    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})