Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Shortener/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
('Google', 'Google URL Shortener'),
('Rebrandly', 'Rebrand.ly'),
('Madwire', 'm360.us'),
('Osdb', 'Osdb.link ')
('Osdb', 'Osdb.link '),
('chilpit', 'chilp.it '),
)

class Urlform(forms.Form):
Expand Down
9 changes: 9 additions & 0 deletions Shortener/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def test_worker_shortens_url_with_madwire():
assert url_validator(shortened_url)
assert len(shortened_url) < len(url)

def test_worker_shortens_url_with_chilpit():
url = "http://7bna.net/wallpapers/cat-pictures.html"
host = "Chilpit"

shortened_url = worker(url, host)

assert url_validator(shortened_url)
assert len(shortened_url) < len(url)


def url_validator(url):
try:
Expand Down
3 changes: 3 additions & 0 deletions Shortener/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def worker(url, host):
shortener = Shortener(engine=Rebrandly, timeout=10, api_key=REBRANDLY_TOKEN)
elif host == "Madwire":
shortener = Shortener(engine=Madwire, timeout=10)
elif host == "Chilpit":
shortener = Shortener("Chilpit", timeout=10)

else:
shortener = Shortener(host, timeout=10)
short_url = shortener.short(url)
Expand Down