コード例 #1
0
ファイル: test_privacy.py プロジェクト: vamsi/readthedocs.org
    def _create_kong(self,
                     privacy_level='private',
                     version_privacy_level='private'):
        self.client.login(username='******', password='******')
        log.info(("Making kong with privacy: %s and version privacy: %s" %
                  (privacy_level, version_privacy_level)))
        # Create project via project form, simulate import wizard without magic
        form = UpdateProjectForm(data={
            'repo_type': 'git',
            'repo': 'https://github.com/ericholscher/django-kong',
            'name': 'Django Kong',
            'language': 'en',
            'default_branch': '',
            'project_url': 'http://django-kong.rtfd.org',
            'default_version': 'latest',
            'python_interpreter': 'python',
            'description': 'OOHHH AH AH AH KONG SMASH',
            'documentation_type': 'sphinx'
        },
                                 user=User.objects.get(username='******'))
        proj = form.save()
        # Update these directly, no form has all the fields we need
        proj.privacy_level = privacy_level
        proj.version_privacy_level = version_privacy_level
        proj.num_minor = 2
        proj.num_major = 2
        proj.num_point = 2
        proj.save()

        self.assertAlmostEqual(Project.objects.count(), 1)
        r = self.client.get('/projects/django-kong/')
        self.assertEqual(r.status_code, 200)
        return Project.objects.get(slug='django-kong')
コード例 #2
0
ファイル: test_privacy.py プロジェクト: cshoe/readthedocs.org
    def _create_kong(self, privacy_level="private", version_privacy_level="private"):
        self.client.login(username="******", password="******")
        log.info(("Making kong with privacy: %s and version privacy: %s" % (privacy_level, version_privacy_level)))
        # Create project via project form, simulate import wizard without magic
        form = UpdateProjectForm(
            data={
                "repo_type": "git",
                "repo": "https://github.com/ericholscher/django-kong",
                "name": "Django Kong",
                "language": "en",
                "default_branch": "",
                "project_url": "http://django-kong.rtfd.org",
                "default_version": LATEST,
                "python_interpreter": "python",
                "description": "OOHHH AH AH AH KONG SMASH",
                "documentation_type": "sphinx",
            },
            user=User.objects.get(username="******"),
        )
        proj = form.save()
        # Update these directly, no form has all the fields we need
        proj.privacy_level = privacy_level
        proj.version_privacy_level = version_privacy_level
        proj.num_minor = 2
        proj.num_major = 2
        proj.num_point = 2
        proj.save()

        self.assertAlmostEqual(Project.objects.count(), 1)
        r = self.client.get("/projects/django-kong/")
        self.assertEqual(r.status_code, 200)
        return Project.objects.get(slug="django-kong")
コード例 #3
0
ファイル: test_privacy.py プロジェクト: 1and1/readthedocs.org
    def _create_kong(self, privacy_level='private',
                     version_privacy_level='private'):
        self.client.login(username='******', password='******')
        log.info(("Making kong with privacy: %s and version privacy: %s"
                  % (privacy_level, version_privacy_level)))
        # Create project via project form, simulate import wizard without magic
        form = UpdateProjectForm(
            data={'repo_type': 'git',
                  'repo': 'https://github.com/ericholscher/django-kong',
                  'name': 'Django Kong',
                  'language': 'en',
                  'default_branch': '',
                  'project_url': 'http://django-kong.rtfd.org',
                  'default_version': 'latest',
                  'python_interpreter': 'python',
                  'description': 'OOHHH AH AH AH KONG SMASH',
                  'documentation_type': 'sphinx'},
            user=User.objects.get(username='******'))
        proj = form.save()
        # Update these directly, no form has all the fields we need
        proj.privacy_level = privacy_level
        proj.version_privacy_level = version_privacy_level
        proj.num_minor = 2
        proj.num_major = 2
        proj.num_point = 2
        proj.save()

        self.assertAlmostEqual(Project.objects.count(), 1)
        r = self.client.get('/projects/django-kong/')
        self.assertEqual(r.status_code, 200)
        return Project.objects.get(slug='django-kong')
コード例 #4
0
ファイル: test_forms.py プロジェクト: J-KAM/ProTrack
    def test_valid_form(self):
        form_data = {
            'name': 'Project',
            'project_type': 'g',
            'git_owner': 'J-KAM',
            'git_name': 'ProPRo',
            'description': 'opis projekta'
        }

        form = UpdateProjectForm(data=form_data)
        self.assertTrue(form.is_valid())
コード例 #5
0
ファイル: views.py プロジェクト: andrewsmedina/djangodash2011
def change_project(request, id_project):
    project = get_object_or_404(Project, id=id_project)

    if request.method == 'POST':
        form = UpdateProjectForm(request.POST, instance=project)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/panel/projects/%d/' % form.instance.id)
    else:
        form = UpdateProjectForm(instance=project)

    return TemplateResponse(request, 'panel/project_form.html', {'form': form})
コード例 #6
0
ファイル: test_views.py プロジェクト: vamsi/readthedocs.org
    def test_imported_docs(self):
        # Test Import
        self.client.login(username='******', password='******')
        user = User.objects.get(username='******')
        r = self.client.get('/dashboard/', {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get('/dashboard/import/manual/', {})
        self.assertEqual(r.status_code, 200)
        form = UpdateProjectForm(data={
            'name':
            'Django Kong',
            'repo':
            'https://github.com/ericholscher/django-kong',
            'repo_type':
            'git',
            'description':
            'OOHHH AH AH AH KONG SMASH',
            'language':
            'en',
            'default_branch':
            '',
            'project_url':
            'http://django-kong.rtfd.org',
            'default_version':
            'latest',
            'privacy_level':
            'public',
            'version_privacy_level':
            'public',
            'python_interpreter':
            'python',
            'documentation_type':
            'sphinx',
            'csrfmiddlewaretoken':
            '34af7c8a5ba84b84564403a280d9a9be',
        },
                                 user=user)
        _ = form.save()
        _ = Project.objects.get(slug='django-kong')

        r = self.client.get('/docs/django-kong/en/latest/', {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get('/dashboard/django-kong/versions/', {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get('/builds/django-kong/')
        self.assertEqual(r.status_code, 200)
        r = self.client.get('/dashboard/django-kong/edit/', {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get('/dashboard/django-kong/subprojects/', {})
        self.assertEqual(r.status_code, 200)
コード例 #7
0
ファイル: test_forms.py プロジェクト: J-KAM/ProTrack
    def test_required_fields(self):
        form = UpdateProjectForm()

        self.assertTrue(form.fields['name'].required)
        self.assertTrue(form.fields['project_type'].required)
        self.assertFalse(form.fields['git_owner'].required)
        self.assertFalse(form.fields['git_name'].required)
        self.assertFalse(form.fields['description'].required)
コード例 #8
0
ファイル: test_forms.py プロジェクト: J-KAM/ProTrack
    def test_field_labels(self):
        form = UpdateProjectForm()

        self.assertTrue(form.fields['name'].label is None
                        or form.fields['name'].label == 'Name')
        self.assertTrue(form.fields['project_type'].label is None
                        or form.fields['project_type'].label == 'Project type')
        self.assertTrue(form.fields['git_owner'].label is None
                        or form.fields['git_owner'].label == 'Git owner')
        self.assertTrue(form.fields['git_name'].label is None
                        or form.fields['git_name'].label == 'Git name')
        self.assertTrue(form.fields['description'].label is None
                        or form.fields['description'].label == 'Description')
コード例 #9
0
ファイル: test_views.py プロジェクト: cshoe/readthedocs.org
    def test_imported_docs(self):
        # Test Import
        self.client.login(username="******", password="******")
        user = User.objects.get(username="******")
        r = self.client.get("/dashboard/", {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get("/dashboard/import/manual/", {})
        self.assertEqual(r.status_code, 200)
        form = UpdateProjectForm(
            data={
                "name": "Django Kong",
                "repo": "https://github.com/ericholscher/django-kong",
                "repo_type": "git",
                "description": "OOHHH AH AH AH KONG SMASH",
                "language": "en",
                "default_branch": "",
                "project_url": "http://django-kong.rtfd.org",
                "default_version": LATEST,
                "privacy_level": "public",
                "version_privacy_level": "public",
                "python_interpreter": "python",
                "documentation_type": "sphinx",
                "csrfmiddlewaretoken": "34af7c8a5ba84b84564403a280d9a9be",
            },
            user=user,
        )
        _ = form.save()
        _ = Project.objects.get(slug="django-kong")

        r = self.client.get("/docs/django-kong/en/latest/", {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get("/dashboard/django-kong/versions/", {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get("/builds/django-kong/")
        self.assertEqual(r.status_code, 200)
        r = self.client.get("/dashboard/django-kong/edit/", {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get("/dashboard/django-kong/subprojects/", {})
        self.assertEqual(r.status_code, 200)
コード例 #10
0
    def test_imported_docs(self):
        # Test Import
        self.client.login(username='******', password='******')
        user = User.objects.get(username='******')
        r = self.client.get('/dashboard/', {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get('/dashboard/import/manual/', {})
        self.assertEqual(r.status_code, 200)
        form = UpdateProjectForm(data={
            'name': 'Django Kong',
            'repo': 'https://github.com/ericholscher/django-kong',
            'repo_type': 'git',
            'description': 'OOHHH AH AH AH KONG SMASH',
            'language': 'en',
            'default_branch': '',
            'project_url': 'http://django-kong.rtfd.org',
            'default_version': LATEST,
            'privacy_level': 'public',
            'version_privacy_level': 'public',
            'python_interpreter': 'python',
            'documentation_type': 'sphinx',
            'csrfmiddlewaretoken': '34af7c8a5ba84b84564403a280d9a9be',
        }, user=user)
        _ = form.save()
        _ = Project.objects.get(slug='django-kong')

        r = self.client.get('/docs/django-kong/en/latest/', {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get('/dashboard/django-kong/versions/', {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get('/builds/django-kong/')
        self.assertEqual(r.status_code, 200)
        r = self.client.get('/dashboard/django-kong/edit/', {})
        self.assertEqual(r.status_code, 200)
        r = self.client.get('/dashboard/django-kong/subprojects/', {})
        self.assertEqual(r.status_code, 200)
コード例 #11
0
def change_project(request, id_project):
    project = get_object_or_404(Project, id=id_project)

    if request.method == 'POST':
        form = UpdateProjectForm(request.POST, instance=project)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/panel/projects/%d/' %
                                        form.instance.id)
    else:
        form = UpdateProjectForm(instance=project)

    return TemplateResponse(request, 'panel/project_form.html', {'form': form})
コード例 #12
0
ファイル: test_forms.py プロジェクト: J-KAM/ProTrack
    def test_invalid_form(self):
        form_data = {'description': 'opis projekta'}

        form = UpdateProjectForm(data=form_data)
        self.assertFalse(form.is_valid())
コード例 #13
0
ファイル: test_forms.py プロジェクト: J-KAM/ProTrack
    def test_field_number(self):
        form = UpdateProjectForm()

        self.assertEqual(len(form.fields), 5)