-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into pyup-update-simplejson-3.10.0-to-3.11.1
- Loading branch information
Showing
7 changed files
with
133 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
language: python | ||
python: | ||
- "2.6" | ||
- "2.7" | ||
services: | ||
- postgresql | ||
env: | ||
global: | ||
- DJANGO_DEBUG=1 | ||
- UPLOADCARE_DISABLED=1 | ||
- ROLLBAR_DISABLED=1 | ||
- DJANGO_SECRET_KEY=foo | ||
- DATABASE_URL=postgres://[email protected]/travis_ci_test | ||
- HOSTNAMES=localhost | ||
install: | ||
- pip install -r requirements.txt | ||
before_script: | ||
- psql -c 'CREATE DATABASE travis_ci_test;' -U postgres | ||
script: | ||
- python manage.py test pylinks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from django.test import Client, TestCase | ||
from django.core.urlresolvers import reverse | ||
|
||
from .models import Category, Link | ||
|
||
class CategoryModelTests(TestCase): | ||
|
||
def test_category_sort(self): | ||
Category(title='Test 2', slug='test2').save() | ||
Category(title='Test 1', slug='test1').save() | ||
|
||
self.assertEqual(['Test 1', 'Test 2'], map(str, Category.objects.all())) | ||
|
||
class LinkModelTests(TestCase): | ||
def setUp(self): | ||
self.url = 'https://github.com/' | ||
self.link = Link(title='GitHub', url=self.url) | ||
|
||
def test_track_link(self): | ||
self.assertEqual(self.link.get_absolute_url(), self.url) | ||
self.link.save() | ||
self.assertEqual(self.link.visits, 0) | ||
self.assertEqual(self.link.get_absolute_url(), | ||
reverse('track_link', kwargs={'link_id': self.link.id})) | ||
|
||
def test_link_title(self): | ||
self.assertEqual(str(self.link), 'GitHub') | ||
|
||
def test_increment_visits(self): | ||
self.link.save() | ||
response = self.client.get( | ||
reverse('track_link', kwargs={'link_id': self.link.id})) | ||
self.assertEqual(response.status_code, 302) | ||
self.assertEqual(response['Location'], self.link.url) | ||
self.assertEqual(Link.objects.get(pk=self.link.id).visits, 1) | ||
|
||
class ListViewTests(TestCase): | ||
def setUp(self): | ||
ca = Category(title='A', slug='a') | ||
ca.save() | ||
cb = Category(title='B', slug='b') | ||
cb.save() | ||
|
||
link = Link(title='Google', url='https://www.google.ca', visits=1) | ||
link.save() | ||
ca.links.add(link) | ||
|
||
link = Link(title='GitHub', url='https://github.com', visits=2) | ||
link.save() | ||
ca.links.add(link) | ||
|
||
link = Link(title='UW', url='https://uwaterloo.ca', visits=3) | ||
link.save() | ||
cb.links.add(link) | ||
|
||
class CategoryListViewTests(ListViewTests): | ||
def test_category_list(self): | ||
response = self.client.get(reverse('category_links', kwargs={'slug': 'a'})) | ||
self.assertQuerysetEqual(response.context['links'], [ | ||
'<Link: GitHub>', | ||
'<Link: Google>' | ||
]) | ||
|
||
class PopularListViewTests(ListViewTests): | ||
def test_popular_list(self): | ||
response = self.client.get(reverse('popular_links')) | ||
self.assertQuerysetEqual(response.context['links'], [ | ||
'<Link: UW>', | ||
'<Link: GitHub>', | ||
'<Link: Google>' | ||
]) | ||
|
||
class RecentListViewTests(ListViewTests): | ||
def test_recent_list(self): | ||
response = self.client.get(reverse('recent_links')) | ||
self.assertQuerysetEqual(response.context['links'], [ | ||
'<Link: UW>', | ||
'<Link: GitHub>', | ||
'<Link: Google>' | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters