Commit Graph

870 Commits

Author SHA1 Message Date
Ryan P Kilby
b64f8066c0 Add json util wrapper, failing JSONField test 2017-09-25 09:08:20 +02:00
Ryan P Kilby
f6c19e5eac Remove DjangoFilterBackend and associated tests 2017-09-20 16:47:54 +02:00
Carlton Gibson
7d6d043531 Fix DateTimeField TZ handling (#5435)
* Add failing TZ tests for DateTimeField

- tests "current" timezone activation
- tests output for non-UTC timezones

* Update DateTimeField TZ aware/naive test output

* Fix DateTimeField TZ handling

* Add Release Note for BC change
2017-09-20 12:15:15 +02:00
Jeremy Nauta
c0a48622e1 Allow ChoiceField.choices to be set dynamically (#5426)
## Description

The `choices` field for the `ChoiceField` class should be able to be edited after `ChoiceField.__init__` is called.

```
field = ChoiceField(choices=[1,2])
field.choices = [1]  # Should no longer allow `2` as a choice
```

Currently, you must update `choices`, `grouped_choices`, and `choice_strings_to_values` to achieve this. This P/R keeps `grouped_choices` and `choice_strings_to_values` in sync whenever the `choices` are edited.
2017-09-20 11:33:50 +02:00
Carlton Gibson
7b1582e00e Allow schema = None. Deprecate exclude_from_schema (#5422)
* Add tests for schema exclusions

* Move exclusion check to should_include_endpoint

* Update docs

* Switch to using `schema = None`

* Test PendingDeprecationWarnings

* Add note to release notes.

* s/deprecated/pending deprecation/

* Add PR link to release notes

* Correct typo in test class name

* Test 'exclude_from_schema' deprecation warning message (#1)

* Correct deprecation warning message
2017-09-20 11:29:47 +02:00
Carlton Gibson
efff9ff338 5378 fix schema generation markdown (#5421)
* Test case for #5240
* Remove unnecessary strip()  from get_description

Closes #5240

* Adjust test case
2017-09-14 12:20:41 +01:00
Carlton Gibson
d54df8c438 Refactor schema generation to allow per-view customisation (#5354)
* Initial Refactor Step

* Add descriptor class
* call from generator
* proxy back to generator for implementation.

* Move `get_link` to descriptor

* Move `get_description` to descriptor

* Remove need for generator in get_description

* Move get_path_fields to descriptor

* Move `get_serializer_fields` to descriptor

* Move `get_pagination_fields` to descriptor

* Move `get_filter_fields` to descriptor

* Move `get_encoding` to descriptor.

* Pass just `url` from SchemaGenerator to descriptor

* Make `view` a property

Encapsulates check for a view instance.

* Adjust API Reference docs

* Add `ManualSchema` class

* Refactor to `ViewInspector` plus `AutoSchema`

The interface then is **just** `get_link()`

* Add `manual_fields` kwarg to AutoSchema

* Add schema decorator for FBVs

* Adjust comments

* Docs: Provide full params in example

Ref feedback b52e372f8f (r137254795)

* Add docstring for ViewInstpector.__get__ descriptor method.

Ref https://github.com/encode/django-rest-framework/pull/5354#discussion_r137265022

* Make `schemas` a package.

* Split generators, inspectors, views.

* Adjust imports

* Rename to EndpointEnumerator

* Adjust ManualSchema to take `fields`

… and `description`.

Allows `url` and `action` to remain dynamic

* Add package/module docstrings
2017-09-14 09:46:34 +01:00
Sergei Azarkin
9aaea2586b Fix authtoken managment command (#5415)
* Fix authtoken managment command username param
2017-09-12 14:03:29 +01:00
Ryan P Kilby
ae95ed1ec2 Add repr(value) to the assert msg in FieldValues 2017-09-11 05:18:39 -04:00
Carlton Gibson
71ad99e0b2 Merge pull request #5388 from founders4schools/fix/named-source
Fix ModelSerializer custom named fields with source on model
2017-09-04 17:24:36 +02:00
jhg14
66b2c6149e Fix code style 2017-09-04 16:17:43 +01:00
jhg14
4345894445 Add simplest possible failing test 2017-09-04 15:44:10 +01:00
jhg14
3c1bf6bfd5 Add failing test for named attribute
Fix test crudely

Remove comment
2017-09-04 15:44:04 +01:00
Igor Tokarev
79be20a7c6 Updated supported values for the NullBooleanField (#5387)
* Updated supported values for the NullBooleanField.
* Added check for unhashable types in NullBooleanField.
2017-09-04 10:11:53 +01:00
Carlton Gibson
7cd59147ea Merge pull request #5376 from rpkilby/django-perms-queryset
DjangoModelPermissions should perform auth check before accessing the view's queryset
2017-09-04 08:24:40 +02:00
Ryan P Kilby
23b2d8099b Unify QS handling for model/object permissions 2017-09-01 13:56:39 -04:00
Ryan P Kilby
bc49746dd3 Fix test name 2017-08-31 08:26:14 -04:00
Carlton Gibson
27c382c98d Merge pull request #5351 from rpkilby/requestfactory-contenttype
Unexpected result when passing empty body to RequestFactory
2017-08-31 12:13:49 +02:00
Ryan P Kilby
0ec915e623 Force content_type inclusion in APIRequestFactory 2017-08-31 05:45:12 -04:00
Ryan P Kilby
2ea368e80f Add failing test for #5367 2017-08-30 16:53:08 -04:00
Ryan P Kilby
79c1f2154a Fix authorization few perms tests 2017-08-30 16:52:38 -04:00
Ryan P Kilby
94e5d05caa Add failing test for #5371 2017-08-30 14:06:43 -04:00
Ryan P Kilby
eb88687e28 Test RequestFactory with empty body 2017-08-22 15:02:18 -04:00
Carlton Gibson
d2286ba658 Merge pull request #5326 from limdauto/limdauto-patch-1
Fix introspection of list field in schema
2017-08-21 10:09:57 +02:00
Lim H
56021f9e77 Add tests for list field to schema 2017-08-20 17:12:56 +01:00
Woile
a1546cc266 [NEW] Tests for templatetags.schema_links 2017-08-17 21:14:26 +02:00
Alexander Dutton
e80b78d1cb RemoteUserAuthentication, docs, and tests (#5306)
RemoteUserAuthentication, docs, and tests
2017-08-11 10:35:00 +01:00
Ryan P Kilby
26ebb88306 Revert 3288 (#5313)
* Add regression test for #2505. Thanks @pySilver!

* Add regression test for #5087

* Revert "Cached the field's root and context property."

This reverts commit 792005806b.
2017-08-07 16:52:09 +01:00
Ryan P Kilby
d1cfec8d87 Fix SearchFilter to-many behavior by ANDing cond's 2017-07-10 14:50:47 -04:00
Ryan P Kilby
f02b7f1329 Add failing test for #4655 2017-07-10 14:20:23 -04:00
Tom Christie
6d4d4dfd04 Ensure closables in request.FILES get closed. (#5262)
Ensure closables on `.FILES` get closed.
2017-07-10 13:42:02 +01:00
Tom Christie
39f6f1137c Merge pull request #5261 from encode/validation-error-on-invalid-timezone-parsing
Raise validation error on invalid timezone parsing.
2017-07-10 11:27:28 +01:00
Tom Christie
41901185d2 Ignore timezone test case for Django 1.8, due to differing behavior. 2017-07-10 11:18:26 +01:00
Tom Christie
fbb3490989 Merge pull request #5188 from andreagrandi/auth-token-cmd
Add Django manage command to create a DRF user Token
2017-07-10 10:35:05 +01:00
Tom Christie
7d240a2e50 Minor cleanup in test. 2017-07-10 10:30:39 +01:00
Tom Christie
c7e2bad524 Merge pull request #5189 from myrubapa/master
Fix API documentation templates do not check for user authentication #5162
2017-07-10 10:28:33 +01:00
Tom Christie
bf7fcc495b Raise validation error on invalid timezone parsing. 2017-07-10 10:14:31 +01:00
Tom Christie
3dab905656 Merge pull request #5231 from dmmatson/feature/slugfield-allow-unicode
Fixed tests on Windows. Added unicode support to SlugField
2017-07-07 12:41:52 +01:00
dmmatson
302a9d089e Fixed tests on Windows. Added unicode support to SlugField 2017-06-23 23:11:17 -06:00
Venelin Stoykov
0e5d26fa6a Fixed #5228 Set ViewSet args/kwargs/request before dispatch 2017-06-22 16:22:17 +03:00
Tom Christie
598e5877cd Merge pull request #5192 from matteius/DRF-5135-one-to-one-pk
Special case for when OneToOneField is also primary key.
2017-06-16 12:06:12 +01:00
Andrea Grandi
d2459710ca Implement option to reset User token 2017-06-03 11:58:01 +01:00
Andrea Grandi
be590d61c0 Handle invalid User situation 2017-05-31 23:01:35 +01:00
Matt Davis
88f9dbceec Silly linting change
import ordering matters
2017-05-30 14:13:29 -04:00
Matt Davis
6115815108 Special case for when OneToOneField is also primary key.
https://github.com/encode/django-rest-framework/issues/5135
2017-05-30 13:57:45 -04:00
Bekhzod Tillakhanov
31d6ef1ba2 Remove new line 2017-05-30 20:36:46 +05:00
Bekhzod Tillakhanov
84e22cc2f3 Scheme fix when unauth and Flask8 lint fix 2017-05-30 00:15:07 +05:00
Andrea Grandi
d198b1abe6 Add Django manage command to create a DRF user Token 2017-05-29 17:07:50 +01:00
Tom Christie
9c9525b130 Merge pull request #5187 from mathpresso-mom/list_route_regex
Fix list_route, detail_route with kwargs contains curly bracket in url_path
2017-05-29 13:47:19 +01:00
Tom Christie
e2157fbf7c Merge pull request #5174 from tadhg-ohiggins/html_cutoff_none
Fix exception when HTML_CUTOFF is set to None
2017-05-29 11:54:03 +01:00
Dryice Liu
836328594b add test 2017-05-29 08:27:07 +08:00
이동환
973860d9fe Added: test for list_route and detail_route with regex url_path 2017-05-28 18:38:09 +09:00
Mariusz Felisiak
a002bb5c67
Fixed test_hyperlinked_related_lookup_url_encoded_exists.
Space character ' ' is prohibited in IRIs, therefore we shouldn't
rely on encoding '%20' to ' ' in the HyperlinkedRelatedField tests.
2017-05-26 09:56:26 +02:00
Tadhg O'Higgins
99782c2160 Add tests for HTML_CUTOFF setting and fix issue where setting it to None would raise an exception. 2017-05-24 16:46:18 -07:00
Thomas Achtemichuk
c9c383dfad
Don't trim whitespace from authtoken passwords
* Fixes #5148
2017-05-17 14:52:39 -04:00
Daniel Hahler
17bf312408 fixup! Add failing test
[ci skip]
2017-05-16 12:10:45 +02:00
Daniel Hahler
2b199f7588 Add failing test 2017-05-16 12:02:23 +02:00
Vimarsh Chaturvedi
7b4afdc737 Merge branch 'master' into issue4989 2017-05-13 19:10:47 +05:30
vimarshc
b2d6149301 importing regex constant to remove invalid parameters. 2017-05-13 05:14:32 +05:30
vimarshc
ed70f5636a Added failing test case for multiple hyphens in orderingfilter paramter 2017-05-11 12:56:41 +05:30
Nabil Jamaleddine
cdb8a3c3c8 Add ValidationError to except in get_object_or_404 for django 1.11 2017-05-05 21:17:12 -04:00
Ryan P Kilby
53b100d03d Add failing test for filter backend mro 2017-05-03 12:50:40 -04:00
Tom Christie
97312699f5 Merge pull request #5085 from hurturk/schema-method-limited
Generate schema with respect to http_method_names provided by CBV
2017-05-03 09:16:01 +01:00
Tom Christie
dea601dc86 Merge pull request #4222 from NewVadim/master
Fix partial update for the ListSerializer.
2017-05-02 10:17:12 +01:00
Tom Christie
5ba2368ff9 Merge pull request #4987 from halfstrik/master
Added test for DateTimeField validation when server has timezone with…
2017-04-27 17:22:27 +01:00
hurturk
2196cd2bbb Generate schema with respect to http_method_names provided by CBV 2017-04-18 23:44:18 -04:00
Maciej Urbanski
5e185aa26b add URL path unquote to HyperlinkedRelatedField.to_internal_value 2017-04-14 01:56:44 +02:00
Tom Christie
33290170e8 Merge pull request #5060 from jpadilla/encode
Update links after moving to encode org
2017-04-07 17:20:51 +01:00
José Padilla
c1f31492ae
Update links after moving to encode org 2017-04-07 10:28:35 -04:00
Ian Cordasco
c2ee1b3033 Use overridden settings exception handler
Instead of using the api_settings exception handler, we use the
overridden settings attribute to find the correct handler.

Closes #5054
2017-04-06 14:05:29 -05:00
Ekluv
d66304abe6 update test case 2017-03-28 12:02:03 +05:30
Ekluv
ef8092ba2f update test case 2017-03-28 11:50:55 +05:30
Ekluv
56fe0e4b3f fix unique=True validation for ChoiceField 2017-03-28 00:38:21 +05:30
Sergey Petrunin
b0a0c30bfe Added pytz exception in compat module.
Mock pytz.timezone localize in tests.
Ref: #4986
2017-03-22 00:03:32 -04:00
Sergey Petrunin
e4a1bd140b Update error message.
Ref: #4986
2017-03-20 18:47:25 -04:00
Sergey Petrunin
d4726dab81 Fix bug for not existent or ambiguous datetime during native to aware conversion in timezone with DST.
Ref: #4986
2017-03-18 23:13:26 -04:00
Sergey Petrunin
1ee54fb85c Added test for DateTimeField validation when server has timezone with DST and input is a native time in a DST shift interval.
Added pytz to requirements-testing.txt to reproduce the case.
2017-03-15 23:45:41 -04:00
Tom Christie
43b38964ea Support HEAD in viewsets 2017-03-13 12:51:03 +00:00
Asif Saifuddin Auvi
baea07c511 converted testing test asserts to pytest (#4949)
* converted testing test asserts to pytest

* moved 3rd arg from test_empty_post_uses_default_boolean_value test assert
2017-03-10 09:00:00 +00:00
Tom Christie
52db57a6e7 Version 3.6 (#4943) 2017-03-09 14:49:51 +00:00
Tibo Beijen
cf5d401a0e Allow required false and default (#4692)
* Default value will now be used when serializing if key or attribute is missing.
2017-03-07 13:19:19 +00:00
Tom Christie
68d2020112 Live API documentation (#4755) 2017-03-03 15:24:37 +00:00
Tim Watts
8df340908b Add failing tests and fix for dict that have a key items #4931 (#4932) 2017-03-03 09:23:09 +00:00
tdruez
d616c1591f Added a test to cover the DjangoModelPermissions #4927 issue
`DjangoObjectPermissions` and `DjangoModelPermissions` are now properly cover for the `METHOD_NOT_ALLOWED` issue
2017-03-01 09:50:21 +01:00
tdruez
c30ccac38e Added a failing test for #4927 2017-02-27 20:39:47 +01:00
Ran Benita
7a408f6cd2 Guard against the possible misspelling readonly_fields in model serializers
Fixes #4897.
2017-02-22 13:27:23 +02:00
Isaac Stone
289e1e440e Check for collection.Mapping instead of dict
issue #4901
2017-02-19 13:10:03 -08:00
Mariusz Felisiak
cd469f616a
Increased utils/encoders.py test coverage. 2017-02-15 07:17:33 +01:00
李扬
cbad236f6d Add max_length and min_length arguments for ListField (#4877) 2017-02-06 09:36:03 +00:00
Mariusz Felisiak
b99272c425
Fixed dedent for tab indent. 2017-01-31 20:57:52 +01:00
Artem Muterko
d610d150f1 Add test for pagination when limit not set 2017-01-31 16:51:09 +02:00
Mariusz Felisiak
3001b56e06 Fixed Django 2.0 compatibility due to django.conf.urls.include parameters change. (#4866) 2017-01-30 16:11:19 +00:00
Artem Muterko
31e9f7dfbb Add remaining tests for generics (#4865) 2017-01-30 11:08:03 +00:00
Artem Muterko
220be31791 Git add remaining tests for BaseSerializer (#4857) 2017-01-27 15:44:00 +00:00
Artem Muterko
d0eb2e6cae Add remaining tests for metadata (#4855) 2017-01-27 09:25:51 +00:00
Artem Muterko
21166a3ab6 Add couple of tests for filters (#4849) 2017-01-25 14:35:12 +00:00
Artem Muterko
48b5aa71f2 Refactor according to comments in PR (#4848) 2017-01-25 10:38:27 +00:00
Artem Muterko
9c8adb4812 Add couple of tests for compat module (#4845) 2017-01-24 12:50:35 +00:00
Mariusz Felisiak
6b399f1193 Fixed test_one_to_one_with_inheritance. Added required on_delete attribute to OneToOneField field. (#4838) 2017-01-24 09:56:46 +00:00
Mariusz Felisiak
5c0f9f147c Removed unnecessary utc wrapper. (#4839) 2017-01-23 16:22:32 +00:00
Artem Muterko
247954d497 Add tests for BasicAuthentication and TokenAuthentication (#4837)
* Add tests for BasicAuthentication

* Add tests for Token authentication

* Adjust test to pass on Django 1.8
2017-01-23 15:08:59 +00:00
José Padilla
d686b2cb15 Merge pull request #4834 from auvipy/slug
converted test asserts of relations slug to pytest
2017-01-20 15:42:20 -05:00
Asif Saifuddin Auvi
d2ae41529c fix wrong assert 2017-01-21 02:25:36 +06:00
Asif Saifuddin Auvi
63d8dc0b9b converted test asserts of relations slug to pytest 2017-01-21 02:14:33 +06:00
Artem Muterko
8043ff3fef Add test for urlquote_wrapper (#4832) 2017-01-20 20:09:47 +00:00
Asif Saifuddin Auvi
1ef334875f converted test asserts of hyperlin relations to pytest 2017-01-21 01:41:45 +06:00
Artem Muterko
0186b073bf Refactor router tests to pytest style 2017-01-19 18:00:07 +02:00
Artem Muterko
c2ce2fb3f0 Add tests for BaseContentNegotiation 2017-01-19 12:50:17 +02:00
Artem Muterko
076ca6e765 Add test for filter_renderers 2017-01-19 12:43:18 +02:00
Artem Muterko
46210205a4 Add tests for some template tags (#4815) 2017-01-18 20:41:32 +00:00
Artem Muterko
a8534baa41 Add remaining tests for validators (#4827) 2017-01-18 20:39:20 +00:00
Xavier Ordoquy
5e9249f429 Merge pull request #4824 from auvipy/newv
new matrix for python 3.6 and django 1.11
2017-01-18 17:24:44 +01:00
Asif Saifuddin Auvi
026a8d8707 make lint happy with isort --recursive 2017-01-18 22:15:44 +06:00
Asif Saifuddin Auvi
006ae46092 remove trailing comma 2017-01-18 21:40:07 +06:00
Asif Saifuddin Auvi
326e09dde9 added utc compat to tests of fields 2017-01-18 20:01:18 +06:00
Artem Muterko
0a496a423d Add tests for qs_exists (#4822) 2017-01-18 11:46:12 +00:00
Artem Muterko
06a5bcc88e Add mediatype tests (#4813) 2017-01-16 18:17:51 +00:00
Artem Muterko
e965270f51 Template html renderer tests (#4817) 2017-01-16 18:16:43 +00:00
Artem Muterko
41ac3565de Add test for delete field (#4819)
* Add test for delete field

* Remove unused import
2017-01-16 13:46:32 +00:00
Artem Muterko
514b5a6dd1 Add couple of test for AuthToken (#4816)
* Add couple of test for AuthToken

* PEP8 cleanup
2017-01-15 08:41:47 +00:00
José Padilla
5efbe17a86 Merge pull request #4808 from micgeronimo/pytest-cleanup
Refactor some tests to pytest style
2017-01-14 08:08:02 -05:00
Artem Muterko
ebd840c19f Revert several tests 2017-01-12 22:53:01 +02:00
Artem Muterko
c686749eef Throttle tests fix (#4810) 2017-01-12 17:53:48 +00:00
Artem Muterko
b4a9a1b9a3 Throttle tests (#4807) 2017-01-12 17:03:32 +00:00
Artem Muterko
9a6352789e Refactor request tests style 2017-01-12 18:41:27 +02:00
Artem Muterko
bd86104861 Refactor reverse tests style 2017-01-12 18:41:16 +02:00
Artem Muterko
401ab54275 Refactor schemas tests style 2017-01-12 18:33:24 +02:00
Asif Saifuddin Auvi
8fcb8d6350 converted metadata test asserts to pytest (#4806) 2017-01-12 08:21:15 +00:00
Artem Muterko
dd11bd42a2 Add remaining tests for SimpleRateThrottle (#4803) 2017-01-11 20:39:48 +00:00
Asif Saifuddin Auvi
14baf7eb7a converted serializer bulk update test asserts to pytest (#4805) 2017-01-11 20:38:32 +00:00
Artem Muterko
06afe6b1bf Convert tests to pytest style 2017-01-11 21:13:30 +02:00
Artem Muterko
66ffaaf5d3 Add more tests for Base and SimpleRate throttles (#4802) 2017-01-11 09:42:25 +00:00
Artem Muterko
e9d371f29a Add couple of basic tests for SimpleRateThrottle (#4800) 2017-01-09 20:43:54 +00:00
Artem Muterko
b6b2c4bb5b Renderer tests (#4791) 2017-01-08 16:33:43 +00:00
Artem Muterko
99d57df990 Convert encoders tests to pytest style (#4796) 2017-01-08 16:10:47 +00:00
Artem Muterko
a5fcf10c0e Raise RuntimeError when trying to encode coreapi objects (#4790) 2017-01-06 22:32:13 +00:00
José Padilla
559a0a89fc Merge pull request #4779 from auvipy/pyts0
converted throttling tests asserts to pytest
2017-01-04 10:31:44 -05:00
Asif Saifuddin Auvi
88a910ebc8 converted negotiation tests asserts to pytest 2017-01-04 18:58:01 +06:00
Asif Saifuddin Auvi
6ca7f76c67 Merge branch 'master' into pyts0 2017-01-04 18:43:55 +06:00
Asif Saifuddin Auvi
43677b8baf flake8 fix 2017-01-04 17:54:14 +06:00
Asif Saifuddin Auvi
8fa5846e51 conerted multi-table-inheritence test asserts to pytest 2017-01-04 17:46:55 +06:00
Asif Saifuddin Auvi
a7d33f4519 conerted throttling tests asserts to pytest 2017-01-04 15:59:21 +06:00
Asif Saifuddin Auvi
7874bcabe9 convert some more test asserts to pytest (#4778)
* converted urlpatterns test asserts to pytest

* converted test utils asserts to pytest

* removed extra newlines
2017-01-04 09:13:32 +00:00
Ryan P Kilby
11fd3bf108 Add disabling of declared fields on serializer subclasses (#4764)
* Add test for disabling declared fields on child
* Check that declared base field is not in attrs
* Update meta inheritance docs to include serializer
* Test that meta fields cannot be declared as None
* Add docs example for declarative field disabling
2017-01-03 21:14:19 +00:00
Matthew Medal
93fe531dea Breadcrumb view name suffix fix (#4750)
* add failing testcase for breadcrumb suffixes missing when using ModelViewSets

* fix get_breadcrumbs to honor overridden get_view_name and keep viewset suffixes

* ensure suffixes are appended in breadcrumb util
2016-12-20 22:19:00 +00:00
Asif Saifuddin Auvi
841a91e950 fix authentication_test pytest failure 2016-12-06 00:47:58 +06:00
Asif Saifuddin Auvi
85807e1958 converted authentication_test asserts to pytest 2016-12-06 00:33:13 +06:00
Asif Saifuddin Auvi
932d04a4be Browsable API tests asserts to pytest (#4725) 2016-12-01 16:17:36 +00:00
Asif Saifuddin Auvi
4f6c326a99 converted remaining unittes asserts of fields test to pytest (#4724) 2016-11-30 12:52:32 +00:00
Asif Saifuddin Auvi
1a741bb2a2 converted asserts of exceptions test to pytest (#4723) 2016-11-30 11:12:01 +00:00