~nataliabidart/locolander/allauth

« back to all changes in this revision

Viewing changes to locolander/locolanderweb/tests/test_models.py

  • Committer: Ricardo Kirkner
  • Author(s): Matias Bordese
  • Date: 2013-06-23 14:21:26 UTC
  • mfrom: (7.1.5 initial-repo-services)
  • Revision ID: ricardo.kirkner@canonical.com-20130623142126-g7u1spb3e9ph0icn
Added projects repo support for launchpad and github.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
from django.core.exceptions import ValidationError
8
8
from django.test import TestCase
9
9
 
10
 
from locolanderweb.models import Project, RunLog
 
10
from locolanderweb.models import (
 
11
    Project,
 
12
    RunLog,
 
13
    ValidationError,
 
14
    service_url_validator,
 
15
)
11
16
 
12
17
 
13
18
class LocoLanderFactory(object):
37
42
        return Project.objects.create(owner=user, url=url)
38
43
 
39
44
 
 
45
class ServiceUrlValidatorTestCase(TestCase):
 
46
 
 
47
    def test_invalid(self):
 
48
        urls = (
 
49
            'locolander',
 
50
            'launchpad.net',
 
51
            'launchpad.net/foo',
 
52
            ###'lp:launchpad.net/foo',
 
53
            'https://github.com/username',
 
54
            'git@github.com:foo/dippi-dapi',
 
55
        )
 
56
        for url in urls:
 
57
            with self.assertRaises(ValidationError) as ctx:
 
58
                service_url_validator(url)
 
59
 
 
60
            e = ctx.exception
 
61
            self.assertIn(url, unicode(e))
 
62
 
 
63
    def test_valid(self):
 
64
        urls = (
 
65
            'http://launchpad.net/locolander',
 
66
            'http://launchpad.net/~pepe/locolander',
 
67
            'https://launchpad.net/locolander',
 
68
            'https://launchpad.net/~pepe/locolander',
 
69
            'lp:locolander',
 
70
            'lp:~pepe/locolander/trunk',
 
71
            'https://github.com/username/yadda-yoda.git',
 
72
            'git@github.com:foo/dippi-dapi.git',
 
73
        )
 
74
        for url in urls:
 
75
            service_url_validator(url)
 
76
 
 
77
 
40
78
class BaseTestCase(TestCase):
41
79
 
42
80
    factory = LocoLanderFactory()