Exemplo n.º 1
0
 def test_basecamp_api_url(self):
     tests = {
         'https://foo.updatelog.com/': self.url_parsing_tests['valid'],
         'http://foo.updatelog.com/': ['http://foo.updatelog.com/projects/8130456/', ],
     }
     for domain, test_cases in tests.items():
         for case in test_cases:
             actual = Project.extract_basecamp_api_url(case)
             msg = "%s != %s for test case %s" % (domain, actual, case)
             self.assertEqual(domain, actual, msg)
Exemplo n.º 2
0
    def clean_basecamp_url(self):
        url = self.cleaned_data['basecamp_url']

        basecamp_id = Project.extract_basecamp_id(url)
        api_url = Project.extract_basecamp_api_url(url)
        if not basecamp_id or not api_url:
            raise forms.ValidationError("%s does not appear to be a valid basecamp url" % url)

        credentials = Project.get_credentials_for(api_url)
        if not credentials:
            raise forms.ValidationError("No credentials for %s" % api_url)

        username, password = credentials

        p = Project.BasecampProject(api_url, basecamp_id, username, password)
        try:
            p.name
        except HTTPError, e:
            raise forms.ValidationError("Error connecting to Basecamp. Does user %s have access to the project?" % username)