Skip to content

Commit

Permalink
Fixed a small settings issue but we now can disable launchpad without…
Browse files Browse the repository at this point in the history
… a problem
  • Loading branch information
pydanny committed Mar 16, 2011
1 parent 225ea31 commit ff14f92
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 33 deletions.
8 changes: 7 additions & 1 deletion apps/package/repos/__init__.py
@@ -1,5 +1,8 @@
from django.conf import settings

import re


def get_all_repos():
return (get_repo(repo_id) for repo_id in supported_repos())

Expand All @@ -16,4 +19,7 @@ def get_repo_for_repo_url(repo_url):
return unsupported_handler

def supported_repos():
return ["bitbucket", "github", "launchpad"]
supported = ["bitbucket", "github"]
if settings.LAUNCHPAD_ACTIVE:
supported += ["launchpad"]
return supported
18 changes: 10 additions & 8 deletions apps/package/tests/test_pulls.py
@@ -1,3 +1,4 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.test import TestCase
Expand Down Expand Up @@ -26,13 +27,14 @@ def setUp(self):
)
package.save()

package = Package.objects.create(
title="Django-PreFlight",
slug="django-preflight",
repo_url="https://code.launchpad.net/~canonical-isd-hackers/django-preflight/trunk",
pypi_url="django-preflight"
)
package.save()
if settings.LAUNCHPAD_ACTIVE:
package = Package.objects.create(
title="Django-PreFlight",
slug="django-preflight",
repo_url="https://code.launchpad.net/~canonical-isd-hackers/django-preflight/trunk",
pypi_url="django-preflight"
)
package.save()

# package list is needed throughout the app
self.packages = Package.objects.all()
Expand Down Expand Up @@ -107,4 +109,4 @@ def test_package_model_fetch(self):
self.assertTrue(package.repo_description)

# TODO check if this is getting updated
#self.assertTrue(package.participants)
#self.assertTrue(package.participants)
48 changes: 25 additions & 23 deletions apps/package/tests/test_repos.py
@@ -1,5 +1,6 @@
# TODO: mock these tests so no network access is required

from django.conf import settings
from django.test import TestCase

from package.repos.bitbucket import repo_handler as bitbucket_handler
Expand Down Expand Up @@ -58,23 +59,24 @@ def test_fetch_metadata(self):
self.package.fetch_commits()


class TestLaunchpadRepo(TestCase):
def setUp(self):
self.package = Package.objects.create(
title="Django-PreFlight",
slug="django-preflight",
repo_url="https://code.launchpad.net/~canonical-isd-hackers/django-preflight/trunk")

def test_fetch_commits(self):
self.assertEqual(Commit.objects.count(), 0)
launchpad_handler.fetch_commits(self.package)
self.assertNotEqual(Commit.objects.count(), 0)

def test_fetch_metadata(self):
package = launchpad_handler.fetch_metadata(self.package)
self.assertTrue(package.repo_watchers > 0)
self.assertTrue(package.repo_forks > 0)
self.assertEqual(package.participants, 'canonical-isd-hackers')
if settings.LAUNCHPAD_ACTIVE:
class TestLaunchpadRepo(TestCase):
def setUp(self):
self.package = Package.objects.create(
title="Django-PreFlight",
slug="django-preflight",
repo_url="https://code.launchpad.net/~canonical-isd-hackers/django-preflight/trunk")

def test_fetch_commits(self):
self.assertEqual(Commit.objects.count(), 0)
launchpad_handler.fetch_commits(self.package)
self.assertNotEqual(Commit.objects.count(), 0)

def test_fetch_metadata(self):
package = launchpad_handler.fetch_metadata(self.package)
self.assertTrue(package.repo_watchers > 0)
self.assertTrue(package.repo_forks > 0)
self.assertEqual(package.participants, 'canonical-isd-hackers')

'''
class TestSourceforgeRepo(TestCase):
Expand Down Expand Up @@ -103,12 +105,12 @@ def test_repo_registry(self):
g = get_repo("github")
self.assertEqual(g.title, "Github")
self.assertEqual(g.url, "https://github.com")

l = get_repo("launchpad")
self.assertEqual(l.title, "Launchpad")
self.assertEqual(l.url, "https://code.launchpad.net")

self.assertTrue("github" in supported_repos())
self.assertTrue("launchpad" in supported_repos())

if settings.LAUNCHPAD_ACTIVE:
l = get_repo("launchpad")
self.assertEqual(l.title, "Launchpad")
self.assertEqual(l.url, "https://code.launchpad.net")
self.assertTrue("launchpad" in supported_repos())

self.assertRaises(ImportError, lambda: get_repo("xyzzy"))
4 changes: 4 additions & 0 deletions docs/install.rst
Expand Up @@ -69,6 +69,10 @@ Change the ``ROOT_URLS`` setting in ``local_settings.py`` from `<root_directory_

ROOT_URLCONF = '<root_directory_name>.urls'

You can enable launchpad support in the local settings file. Launchpad's dependencies can be a little fussy, so this will probably require some additional tweaking on your part::

LAUNCHPAD_ACTIVE = True

Add a Google Analytics code if you have one::

URCHIN_ID = "UA-YOURID123-1"
Expand Down
2 changes: 2 additions & 0 deletions local_settings.py.example
Expand Up @@ -27,6 +27,8 @@ LOCAL_INSTALLED_APPS = []

ROOT_URLCONF = "packaginator.urls"

LAUNCHPAD_ACTIVE = False

# Analytics ID
URCHIN_ID = ""

Expand Down
2 changes: 1 addition & 1 deletion settings.py
Expand Up @@ -272,8 +272,8 @@
"""
}

#: See http://ask.github.com/celery/configuration.html
CELERYD_TASK_TIME_LIMIT = 300
LAUNCHPAD_ACTIVE = False

LOCAL_INSTALLED_APPS = []

Expand Down

0 comments on commit ff14f92

Please sign in to comment.