Re: Testing file upload via a form?

2017-09-10 Thread Derek
Thanks Melvyn Yes, over time I have come to learn the need for fat models and Useful Managers, plus having logic not embedded in the views (especially for processing of data arising from a form). So views are mostly "handlers" to ensure that the forms are presented, the data is retrieved and

Re: Testing file upload via a form?

2017-09-03 Thread Melvyn Sopacua
It certainly isn't trivial. First and foremost, write fat models and Managers, but lean views. Rather then putting complex queries in views, I have a strong bias to writing manager methods (or QuerySet methods, if I feel it's reusable in more then one Manager - see Manager.from_queryset [1]).

Re: Testing file upload via a form?

2017-09-03 Thread Derek
I have been looking for a decent guide that covers testing in a solid, thorough way - there are lots of fragmented pieces that cover bits-and-pieces of what is needed for tests but not all the cases with a start-to-end comprehensive approach for everything ("Obey the Testing Goat" comes closest).

Re: Testing file upload via a form?

2017-09-03 Thread James Schneider
On Sep 1, 2017 3:00 PM, "Derek" wrote: Thanks Melvyn I already have tests for the processing of data when it has been uploaded - which is actually the critical issue for the application. The "view" is just really a thin wrapper around the two steps : form display & upload

Re: Testing file upload via a form?

2017-09-01 Thread Derek
Thanks Melvyn I already have tests for the processing of data when it has been uploaded - which is actually the critical issue for the application. The "view" is just really a thin wrapper around the two steps : form display & upload and then the file processing itself : and those are the parts

Re: Testing file upload via a form?

2017-09-01 Thread Melvyn Sopacua
You're not using the test **Client** at all. You're testing the value of a form.Form instance. The difference is that the test client constructs an actual request, using the known URLs. So you'd need a view and url as well. But these can exist only in the test and to be honest, especially with

Re: Testing file upload via a form?

2017-09-01 Thread Derek
Thanks James, I will try that. On 1 September 2017 at 09:27, James Schneider wrote: > > > On Aug 29, 2017 11:49 AM, "Derek" wrote: > > (Python 3.5 and Django 1.10) > > I am trying to test a Django form that enables a required file upload. > > The

Re: Testing file upload via a form?

2017-09-01 Thread James Schneider
On Aug 29, 2017 11:49 AM, "Derek" wrote: (Python 3.5 and Django 1.10) I am trying to test a Django form that enables a required file upload. The form is very simple and includes a field that looks like: upload_file = forms.FileField() The corresponding test to try

Re: Testing file upload via a form?

2017-09-01 Thread Derek
Thanks Melvyn I thought my code did follow that approach - but it does not seem to work. So either I have not understood the docs (in which case, a point to the specific item is what I need) or there is some other factor at work. On 31 August 2017 at 16:47, Melvyn Sopacua

Re: Testing file upload via a form?

2017-08-31 Thread Melvyn Sopacua
​In the documentation of the test client it is all spelled out how to test file uploads. ​ ​ On Tue, Aug 29, 2017 at 8:48 PM, Derek wrote: > (Python 3.5 and Django 1.10) > > I am trying

Testing file upload via a form?

2017-08-29 Thread Derek
(Python 3.5 and Django 1.10) I am trying to test a Django form that enables a required file upload. The form is very simple and includes a field that looks like: upload_file = forms.FileField() The corresponding test to try and check the upload: def test_form_validation_with_file(self):