Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
23174341
Kaydet (Commit)
23174341
authored
Eyl 27, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Split admin_docs tests into separate files.
üst
62543260
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
166 additions
and
45 deletions
+166
-45
__init__.py
django/contrib/admindocs/tests/__init__.py
+0
-0
test_fields.py
django/contrib/admindocs/tests/test_fields.py
+0
-45
test_middleware.py
tests/admin_docs/test_middleware.py
+44
-0
test_utils.py
tests/admin_docs/test_utils.py
+122
-0
test_views.py
tests/admin_docs/test_views.py
+0
-0
tests.py
tests/admin_docs/tests.py
+0
-0
No files found.
django/contrib/admindocs/tests/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
62543260
django/contrib/admindocs/tests/test_fields.py
deleted
100644 → 0
Dosyayı görüntüle @
62543260
from
__future__
import
unicode_literals
import
unittest
from
django.contrib.admindocs
import
views
from
django.db
import
models
from
django.db.models
import
fields
from
django.utils.translation
import
ugettext
as
_
class
CustomField
(
models
.
Field
):
description
=
"A custom field type"
class
DescriptionLackingField
(
models
.
Field
):
pass
class
TestFieldType
(
unittest
.
TestCase
):
def
setUp
(
self
):
pass
def
test_field_name
(
self
):
self
.
assertRaises
(
AttributeError
,
views
.
get_readable_field_data_type
,
"NotAField"
)
def
test_builtin_fields
(
self
):
self
.
assertEqual
(
views
.
get_readable_field_data_type
(
fields
.
BooleanField
()),
_
(
'Boolean (Either True or False)'
)
)
def
test_custom_fields
(
self
):
self
.
assertEqual
(
views
.
get_readable_field_data_type
(
CustomField
()),
'A custom field type'
)
self
.
assertEqual
(
views
.
get_readable_field_data_type
(
DescriptionLackingField
()),
_
(
'Field of type:
%(field_type)
s'
)
%
{
'field_type'
:
'DescriptionLackingField'
}
)
tests/admin_docs/test_middleware.py
0 → 100644
Dosyayı görüntüle @
23174341
from
__future__
import
unicode_literals
from
django.contrib.auth.models
import
User
from
.tests
import
AdminDocsTestCase
,
TestDataMixin
class
XViewMiddlewareTest
(
TestDataMixin
,
AdminDocsTestCase
):
def
test_xview_func
(
self
):
user
=
User
.
objects
.
get
(
username
=
'super'
)
response
=
self
.
client
.
head
(
'/xview/func/'
)
self
.
assertNotIn
(
'X-View'
,
response
)
self
.
client
.
force_login
(
self
.
superuser
)
response
=
self
.
client
.
head
(
'/xview/func/'
)
self
.
assertIn
(
'X-View'
,
response
)
self
.
assertEqual
(
response
[
'X-View'
],
'admin_docs.views.xview'
)
user
.
is_staff
=
False
user
.
save
()
response
=
self
.
client
.
head
(
'/xview/func/'
)
self
.
assertNotIn
(
'X-View'
,
response
)
user
.
is_staff
=
True
user
.
is_active
=
False
user
.
save
()
response
=
self
.
client
.
head
(
'/xview/func/'
)
self
.
assertNotIn
(
'X-View'
,
response
)
def
test_xview_class
(
self
):
user
=
User
.
objects
.
get
(
username
=
'super'
)
response
=
self
.
client
.
head
(
'/xview/class/'
)
self
.
assertNotIn
(
'X-View'
,
response
)
self
.
client
.
force_login
(
self
.
superuser
)
response
=
self
.
client
.
head
(
'/xview/class/'
)
self
.
assertIn
(
'X-View'
,
response
)
self
.
assertEqual
(
response
[
'X-View'
],
'admin_docs.views.XViewClass'
)
user
.
is_staff
=
False
user
.
save
()
response
=
self
.
client
.
head
(
'/xview/class/'
)
self
.
assertNotIn
(
'X-View'
,
response
)
user
.
is_staff
=
True
user
.
is_active
=
False
user
.
save
()
response
=
self
.
client
.
head
(
'/xview/class/'
)
self
.
assertNotIn
(
'X-View'
,
response
)
tests/admin_docs/test_utils.py
0 → 100644
Dosyayı görüntüle @
23174341
from
__future__
import
unicode_literals
import
unittest
from
django.contrib.admindocs.utils
import
(
docutils_is_available
,
parse_docstring
,
parse_rst
,
trim_docstring
,
)
from
.tests
import
AdminDocsTestCase
@unittest.skipUnless
(
docutils_is_available
,
"no docutils installed."
)
class
TestUtils
(
AdminDocsTestCase
):
"""
This __doc__ output is required for testing. I copied this example from
`admindocs` documentation. (TITLE)
Display an individual :model:`myapp.MyModel`.
**Context**
``RequestContext``
``mymodel``
An instance of :model:`myapp.MyModel`.
**Template:**
:template:`myapp/my_template.html` (DESCRIPTION)
some_metadata: some data
"""
def
setUp
(
self
):
self
.
docstring
=
self
.
__doc__
def
test_trim_docstring
(
self
):
trim_docstring_output
=
trim_docstring
(
self
.
docstring
)
trimmed_docstring
=
(
'This __doc__ output is required for testing. I copied this '
'example from
\n
`admindocs` documentation. (TITLE)
\n\n
'
'Display an individual :model:`myapp.MyModel`.
\n\n
'
'**Context**
\n\n
``RequestContext``
\n\n
``mymodel``
\n
'
' An instance of :model:`myapp.MyModel`.
\n\n
'
'**Template:**
\n\n
:template:`myapp/my_template.html` '
'(DESCRIPTION)
\n\n
some_metadata: some data'
)
self
.
assertEqual
(
trim_docstring_output
,
trimmed_docstring
)
def
test_parse_docstring
(
self
):
title
,
description
,
metadata
=
parse_docstring
(
self
.
docstring
)
docstring_title
=
(
'This __doc__ output is required for testing. I copied this example from
\n
'
'`admindocs` documentation. (TITLE)'
)
docstring_description
=
(
'Display an individual :model:`myapp.MyModel`.
\n\n
'
'**Context**
\n\n
``RequestContext``
\n\n
``mymodel``
\n
'
' An instance of :model:`myapp.MyModel`.
\n\n
'
'**Template:**
\n\n
:template:`myapp/my_template.html` '
'(DESCRIPTION)'
)
self
.
assertEqual
(
title
,
docstring_title
)
self
.
assertEqual
(
description
,
docstring_description
)
self
.
assertEqual
(
metadata
,
{
'some_metadata'
:
'some data'
})
def
test_title_output
(
self
):
title
,
description
,
metadata
=
parse_docstring
(
self
.
docstring
)
title_output
=
parse_rst
(
title
,
'model'
,
'model:admindocs'
)
self
.
assertIn
(
'TITLE'
,
title_output
)
title_rendered
=
(
'<p>This __doc__ output is required for testing. I copied this '
'example from
\n
<a class="reference external" '
'href="/admindocs/models/admindocs/">admindocs</a> documentation. '
'(TITLE)</p>
\n
'
)
self
.
assertHTMLEqual
(
title_output
,
title_rendered
)
def
test_description_output
(
self
):
title
,
description
,
metadata
=
parse_docstring
(
self
.
docstring
)
description_output
=
parse_rst
(
description
,
'model'
,
'model:admindocs'
)
description_rendered
=
(
'<p>Display an individual <a class="reference external" '
'href="/admindocs/models/myapp.mymodel/">myapp.MyModel</a>.</p>
\n
'
'<p><strong>Context</strong></p>
\n
<p><tt class="docutils literal">'
'RequestContext</tt></p>
\n
<dl class="docutils">
\n
<dt><tt class="'
'docutils literal">mymodel</tt></dt>
\n
<dd>An instance of <a class="'
'reference external" href="/admindocs/models/myapp.mymodel/">'
'myapp.MyModel</a>.</dd>
\n
</dl>
\n
<p><strong>Template:</strong></p>'
'
\n
<p><a class="reference external" href="/admindocs/templates/'
'myapp/my_template.html/">myapp/my_template.html</a> (DESCRIPTION)'
'</p>
\n
'
)
self
.
assertHTMLEqual
(
description_output
,
description_rendered
)
def
test_initial_header_level
(
self
):
header
=
'should be h3...
\n\n
Header
\n
------
\n
'
output
=
parse_rst
(
header
,
'header'
)
self
.
assertIn
(
'<h3>Header</h3>'
,
output
)
def
test_parse_rst
(
self
):
"""
parse_rst() should use `cmsreference` as the default role.
"""
markup
=
'<p><a class="reference external" href="/admindocs/
%
s">title</a></p>
\n
'
self
.
assertEqual
(
parse_rst
(
'`title`'
,
'model'
),
markup
%
'models/title/'
)
self
.
assertEqual
(
parse_rst
(
'`title`'
,
'view'
),
markup
%
'views/title/'
)
self
.
assertEqual
(
parse_rst
(
'`title`'
,
'template'
),
markup
%
'templates/title/'
)
self
.
assertEqual
(
parse_rst
(
'`title`'
,
'filter'
),
markup
%
'filters/#title'
)
self
.
assertEqual
(
parse_rst
(
'`title`'
,
'tag'
),
markup
%
'tags/#title'
)
def
test_publish_parts
(
self
):
"""
Django shouldn't break the default role for interpreted text
when ``publish_parts`` is used directly, by setting it to
``cmsreference`` (#6681).
"""
import
docutils
self
.
assertNotEqual
(
docutils
.
parsers
.
rst
.
roles
.
DEFAULT_INTERPRETED_ROLE
,
'cmsreference'
)
source
=
'reST, `interpreted text`, default role.'
markup
=
'<p>reST, <cite>interpreted text</cite>, default role.</p>
\n
'
parts
=
docutils
.
core
.
publish_parts
(
source
=
source
,
writer_name
=
"html4css1"
)
self
.
assertEqual
(
parts
[
'fragment'
],
markup
)
tests/admin_docs/test_views.py
0 → 100644
Dosyayı görüntüle @
23174341
This diff is collapsed.
Click to expand it.
tests/admin_docs/tests.py
Dosyayı görüntüle @
23174341
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment