Пример #1
0
 def test_project_id_detection(self):
     """When given a proper URL it should be able to set it's project_id field."""
     tests = {
         2907852: self.url_parsing_tests['valid'],
         None: self.url_parsing_tests['invalid'],
     }
     
     for basecamp_id, test_cases in tests.items():
         for case in test_cases:
             actual = Project.extract_basecamp_id(case)
             msg = "%s != %s Test case: %s" % (basecamp_id, actual, case)
             self.assertEqual(basecamp_id, actual, msg)
Пример #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)