Re: [Django] #29082: Make the test client automatically encode JSON data

2018-02-06 Thread Django
#29082: Make the test client automatically encode JSON data
-+-
 Reporter:  Nick Sarbicki|Owner:  nobody
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Testing framework|  Version:  2.0
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham ):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"47268242b071895dd269d97540e45dce646f675c" 47268242]:
 {{{
 #!CommitTicketReference repository=""
 revision="47268242b071895dd269d97540e45dce646f675c"
 Fixed #29082 -- Allowed the test client to encode JSON request data.
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.71126a4d9a0d2c492880a8ea416f47e4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-31 Thread Django
#29082: Make the test client automatically encode JSON data
-+-
 Reporter:  Nick Sarbicki|Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Testing framework|  Version:  2.0
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Nick Sarbicki):

 Git went a bit crazy so moved to a new PR here:
 https://github.com/django/django/pull/9645

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.6470fc6c9eb41749d213e2bb400312c8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-31 Thread Django
#29082: Make the test client automatically encode JSON data
-+-
 Reporter:  Nick Sarbicki|Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Testing framework|  Version:  2.0
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * needs_better_patch:  1 => 0


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.3bdf0a0df76f5e21c41a261b733e619b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-31 Thread Django
#29082: Make the test client automatically encode JSON data
-+-
 Reporter:  Nick Sarbicki|Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Testing framework|  Version:  2.0
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * stage:  Accepted => Ready for checkin


Comment:

 All good. I think add the `json_encoder` argument to `__init__` works
 well.

 I'm going to mark as RFC. Good one!

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.8870d142db3dfff5fc2a852001755ec9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-31 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick Sarbicki |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Nick Sarbicki):

 PR updated to reflect the above.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.f2dc91d84101165c4dd20ce29d2102b4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-31 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick Sarbicki |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Nick Sarbicki):

 I was also pondering putting the `if content_type == JSON_CONTENT`
 statement within the `_encode_json` method.

 But I don't think it would be clear enough that we won't actually encode
 JSON if the content_type is something else.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.e2f5fe857a9cbcba4ab1928a4eb30e31%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-31 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick Sarbicki |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Nick Sarbicki):

 I agree, and I like the property idea a lot more - good idea.

 However, I'm not a fan of changing properties after instantiation.


 So I'm going to put it as an `__init__` kwarg. Still have the option of
 changing it post instantiation but you can do it in one line if you want.


 {{{
 factory = test.RequestFactory(json_encoder=MyCustomEncoder)
 req = factory.post('/', content_type='application/json', ...)
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.f905d0c3757ec700647727b3d81402c7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-31 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick Sarbicki |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Carlton Gibson):

 * needs_better_patch:  0 => 1
 * has_patch:  0 => 1


Comment:

 Even if using a custom encoder, it's not something I want to pass every
 time, either calling the request method, or encoding the data explicitly.

 Can we make it an attribute on `RequestFactory` (and so `Client`)?

 `_encode_json` will use this directly, rather than take a parameter: `...
 json.dumps(data, cls=self.json_encoder_class)`

 When testing I set my custom encoder at the point of use (or subclass if I
 prefer):

 {{{
 factory = test.RequestFactory()
 factory.json_encoder_class = MyCustomEncoder
 req = factory.post('/', content_type='application/json', ...)
 }}}

 If we do this then we just need a test that the user **can** set a custom
 encoder.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.2eca4ec6902ce90403db5e8408f03159%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-30 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick Sarbicki |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Tim Graham):

 At first glance, I think adding a `json_encoder` argument to every HTTP
 method in the test client looks like more clutter than its worth. After
 all, a user can use `data=json.dumps({...}, encoder=CustomClass)` for that
 case, correct? That could be documented.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.d21c5e52038f3fbcc542945df6b2a70c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-30 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick Sarbicki |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Nick Sarbicki):

 PR updated for testing all routes.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.2cda9d01e9fc35941aa624952b39c0d3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-30 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick Sarbicki |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Nick Sarbicki):

 PR for the ticket https://github.com/django/django/pull/9636

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.f949c2acb7de4f8450cfe1fed13834db%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-30 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick Sarbicki |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Nick Sarbicki):

 I like the idea but they're two different systems with different APIs, I
 don't want to add more to the interface just to make it feel like
 requests.

 Especially as it would duplicate the keywords functionality with json and
 dicts.

 Maybe it should be a separate ticket?

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.cf443e3099d0b05b097ca50655e0db54%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-29 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick  |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Jonas Haag):

 How about adding a new `json` parameter as in python-requests? From their
 docs:

 {{{
 >>> url = 'https://api.github.com/some/endpoint'
 >>> payload = {'some': 'data'}

 >>> r = requests.post(url, json=payload)
 }}}

 Dealing with requests regularly (and I'm sure I'm not the only one in the
 Python web world who does that) this has become the natural way to specify
 a JSON request body for me. On multiple occasions I just assumed there was
 a `json` parameter on the test client just to be disappointed :)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.723cf8282b7feacdee90e0811d1553dd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-29 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick  |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Nick):

 Fine by me, I have no particular attachment to the encoders and you are
 right, it is nice to have those extras.

 With this accepted I'll try write up a patch tonight/tomorrow.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.1ed657ba25753b34ec061a038addaede%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data

2018-01-29 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick  |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Tom Forbes):

 It would be nice if we could use the Django encoder by default, it does
 some pretty useful things around encoding datetimes, decimals and uuid's
 that I find pretty useful:

 
https://github.com/django/django/blob/3e9aa298719f19d5f09dbe0df29b6bb8d2136229/django/core/serializers/json.py#L76

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.93b93ee39e3426caa6b636344651227a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29082: Make the test client automatically encode JSON data (was: force_bytes from utils.encoding.py produces invalid JSON for RequestFactory)

2018-01-29 Thread Django
#29082: Make the test client automatically encode JSON data
--+
 Reporter:  Nick  |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Testing framework |  Version:  2.0
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Tim Graham):

 * component:  Utilities => Testing framework
 * stage:  Unreviewed => Accepted
 * type:  Bug => Cleanup/optimization


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.c0770821244ee1ee061d204808a265af%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.