Re: testing newbie - help requested: app works, tests give errors

2023-05-10 Thread 'Bob Aalsma' via Django users
Hmm, when I remove the raise CommandError statement and replace it with self.stdout.write, everything works well. This helps me to point further studies. Thx! On Wednesday, May 10, 2023 at 2:33:18 PM UTC+2 Bob Aalsma wrote: > Ah, yes, thanks. > > I hesitate to comment on "If I understood the

Re: testing newbie - help requested: app works, tests give errors

2023-05-10 Thread 'Bob Aalsma' via Django users
Ah, yes, thanks. I hesitate to comment on "If I understood the error right." ;) Umm, my problem here is that I think I'm using the exact same *code* "manually" without errors. I think I'm also using the same *values* for the manual and test runs. So I don't understand the reason for the

Re: testing newbie - help requested: app works, tests give errors

2023-05-10 Thread Vishesh Mangla
If I understood the error right. On Wed, May 10, 2023 at 5:47 PM Vishesh Mangla wrote: > Probably this would help: > https://stackoverflow.com/questions/8609192/what-is-the-difference-between-null-true-and-blank-true-in-django > > On Wed, May 10, 2023 at 5:45 PM 'Bob Aalsma' via Django users <

Re: testing newbie - help requested: app works, tests give errors

2023-05-10 Thread Vishesh Mangla
Probably this would help: https://stackoverflow.com/questions/8609192/what-is-the-difference-between-null-true-and-blank-true-in-django On Wed, May 10, 2023 at 5:45 PM 'Bob Aalsma' via Django users < django-users@googlegroups.com> wrote: > Sorry Vishesh, thanks for the quick answer but I have no

Re: testing newbie - help requested: app works, tests give errors

2023-05-10 Thread 'Bob Aalsma' via Django users
Sorry Vishesh, thanks for the quick answer but I have no idea what you mean. On Wednesday, May 10, 2023 at 2:00:51 PM UTC+2 Vishesh Mangla wrote: > False or True check for yourself. > > On Wed, 10 May, 2023, 17:29 Vishesh Mangla, wrote: > >> It looks like you are passing a null but null=False

Re: testing newbie - help requested: app works, tests give errors

2023-05-10 Thread Vishesh Mangla
False or True check for yourself. On Wed, 10 May, 2023, 17:29 Vishesh Mangla, wrote: > It looks like you are passing a null but null=False is not set > > On Wed, 10 May, 2023, 17:27 'Bob Aalsma' via Django users, < > django-users@googlegroups.com> wrote: > >> I'm trying to test a django-admin

Re: testing newbie - help requested: app works, tests give errors

2023-05-10 Thread Vishesh Mangla
It looks like you are passing a null but null=False is not set On Wed, 10 May, 2023, 17:27 'Bob Aalsma' via Django users, < django-users@googlegroups.com> wrote: > I'm trying to test a django-admin command and don't understand why the > tests give errors on the code while the code works as

Re: Testing django

2023-03-16 Thread Ayush Bisht
Yeah, I got you.. My concern is on the documentation, the way it has provided the commands for executing test cases. That path.to.settings seems confusing sometimes.. On Fri, 17 Mar, 2023, 1:20 am Bhuvnesh Sharma, wrote: > We can run django tests with custom settings by using --settings flag

Re: Testing django

2023-03-16 Thread Bhuvnesh Sharma
We can run django tests with custom settings by using --settings flag and providing the path to the custom settings file . For example: ./runtests.py --settings=new_app.test_settings What do you want to do exactly? On Fri, Mar 17, 2023 at 1:00 AM Ayush Bisht wrote: > Seems like, it is for

Re: Testing django

2023-03-16 Thread Ayush Bisht
Seems like, it is for defining how actually we are selecting the specific test case. It is very confusing at first. Can't we just explain it with an example.. On Friday, March 17, 2023 at 12:54:27 AM UTC+5:30 Ayush Bisht wrote: > * ./runtests.py --settings=path.to.settings

Re: Testing Django User Login Form

2021-04-23 Thread lone...@gmail.com
Thank you for the reply! I will totally try this tonight! On Thursday, April 22, 2021 at 7:31:40 PM UTC-4 David Nugent wrote: > Try creating a request using RequestFactory and use that to input the > credentials. I don't think the way you are creating the form is valid. > > rf =

Re: Testing Django User Login Form

2021-04-22 Thread David Nugent
Try creating a request using RequestFactory and use that to input the credentials. I don't think the way you are creating the form is valid. rf = RequestFactory() request = rf.post('/some_mock_url', dict(username='abc', password='password')) form = AuthenticationForm(request) -- You received

Re: Testing my Django App

2020-03-23 Thread Motaz Hejaze
Delete the sqlite database and migrate again to remake it On Mon, 23 Mar 2020, 7:56 pm victor awakan, wrote: > Check your book.user_id. It shouldn’t be null. That’s what the last error > is saying. > > On Mon 23. Mar 2020 at 17.44, Ejike Enyinnaya > wrote: > >> Good day All, >> >> I am

Re: Testing my Django App

2020-03-23 Thread victor awakan
Check your book.user_id. It shouldn’t be null. That’s what the last error is saying. On Mon 23. Mar 2020 at 17.44, Ejike Enyinnaya wrote: > Good day All, > > I am currently running a test for my Django app call 'Books'. > > Anytime I run an INDEX test, I get the following error below: > > "File

Re: Testing - get_object_or_404 returns 200 status code

2019-06-10 Thread Cristhiam Gabriel Fernández
Hi RyuCoder Should not get_object_or_404 shortcut retry 404 status code? El lunes, 10 de junio de 2019, 15:29:24 (UTC-5), RyuCoder escribió: > > Whats your question? > I failed to understand that  > > On Tue, Jun 11, 2019, 1:45 AM Cristhiam Gabriel Fernández < > cristh...@gmail.com > wrote: >

Re: Testing - get_object_or_404 returns 200 status code

2019-06-10 Thread Chetan Ganji
Whats your question? I failed to understand that  On Tue, Jun 11, 2019, 1:45 AM Cristhiam Gabriel Fernández < cristhiang...@gmail.com> wrote: > Hi Django super heroes > > I'm making of test cases for my simple Django application. When I test a > view with get_object_or_404 shortcut it returns

Re: testing API

2019-04-22 Thread Jani Tiainen
Hi, DRF does have built-in API viewer. To enable that you need to add rest_framework app in your INSTALLED_APPS so it can find necessary templates for showing. On Tue, Apr 23, 2019 at 7:15 AM Shubham Joshi wrote: > I have created the custom model authentication in django rest , so far I > dont

Re: Testing Channels 2.0 consumers - problem with routing

2018-02-11 Thread Andrew Godwin
Hi, This is a known issue with the Redis backend - https://github.com/django/channels/issues/859 I am looking at it today. Andrew On Sun, Feb 11, 2018 at 8:54 AM, Azamat Galimzhanov wrote: > After fixing this issue, here is the updated consumer: > > > from functools

Re: Testing Channels 2.0 consumers - problem with routing

2018-02-11 Thread Azamat Galimzhanov
After fixing this issue, here is the updated consumer: from functools import lru_cache from asgiref.sync import AsyncToSync from channels.generic.websocket import WebsocketConsumer class AuctionConsumer(WebsocketConsumer): @property @lru_cache(maxsize=None) def group_name(self):

Re: Testing Channels 2.0 consumers - problem with routing

2018-02-09 Thread Andrew Godwin
A disconnect() method in your generic consumer takes one argument, a `close_code` - add that in to your function and it will fix it. Feel free to continue problems in this thread, or you can also use GitHub issues on the channels project if you think they're actual bugs! Andrew On Fri, Feb 9,

Re: Testing Channels 2.0 consumers - problem with routing

2018-02-09 Thread Azamat Galimzhanov
Thanks for reply! self.scope looks like this: {'type': 'websocket', 'path': 'auctions/1/', 'headers': [], 'subprotocols': []} I am not sure why url_route is not there. I rewrote my group_name code to use path instead and now this part works. There is a new error though, during disconnect,

Re: Testing Channels 2.0 consumers - problem with routing

2018-02-07 Thread Andrew Godwin
I'm not going to address the mocking, as there's subtle details there (e.g. you mocked group_name as a non-property, I think), but look at the main issue. Can you make your code print out what _is_ in `self.scope`? url_route should definitely be in there, but I am curious what it looks like if it

Re: Testing Channels database data missing in Consumer

2018-02-07 Thread Andrew Godwin
Interesting. I did note that you called ORM methods in an async context, which is not how you are supposed to do it, but I also believe that should work. Maybe try splitting the ORM methods into a separate function and awaiting it using SyncToAsync? As for the staticfiles in live test case

Re: Testing Channels database data missing in Consumer

2018-02-07 Thread Daniel Gilge
Hi Andrew, thanks for your reply. This test is passing (using the same packages): def test_fixture(db_with_segment, admin_client): assert models.MyModel.objects.count() == 1 response = admin_client.get('/api/my_model/list/') assert len(response.json()['results']) == 1 I tried to

Re: Testing Channels database data missing in Consumer

2018-02-06 Thread Andrew Godwin
I'm not quite sure either. Does the test setup work if you are not in async mode? Andrew On Tue, Feb 6, 2018 at 9:45 AM, Daniel Gilge wrote: > Hi, > > this question is related to Channels 2.0, Django 2.0, pytest 3.4, > pytest-django 3.1 and pytest-asyncio 0.8. > > I created

Re: Testing

2018-01-14 Thread yingi keme
Yes it does post Yingi Kem > On 14 Jan 2018, at 10:07 PM, Rich Shepard wrote: > > I've not received messages from this mail list since last summer. I now > have a need to communicate with others and learned that I'm still subscribed > so I want to learn if this

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

Re: testing in django

2017-05-29 Thread Marlysson Silva
If you are using the sqlite database to dummy test , you can in a test case class submit the post to sign up form ( and store at database ) and in other class retrieve the user created previously and performs the login . Em terça-feira, 23 de maio de 2017 04:07:29 UTC-3, Akash Tomar escreveu: >

Re: testing in django

2017-05-23 Thread Antonis Christofides
Hi, one possibility is this: class UserTest(TestCase): def setUp(self): self.my_data = {...} def test_create_account(self): response = self.client.post('/signup/', json.dumps(self.my_data), content_type='application/json')

Re: testing in django

2017-05-23 Thread Александр Христюхин (roboslone)
Perhaps fixtures is what you want: https://code.djangoproject.com/wiki/Fixtures > On 23 May 2017, at 10:07, Akash Tomar wrote: > > class SignUpTest(TestCase): > def test_createAccount(self): > my_data

Re: Testing client's force_login method doesn't seem to be logging in.

2017-03-26 Thread Quentin Fulsher
Actually I just fixed it, You have to save the model after you set the password. On Sunday, March 26, 2017 at 2:35:08 PM UTC-7, Quentin Fulsher wrote: > > I'm trying to write a test case for the viewing permissions on a certain > webpage. I'm trying to get the client to force_login as a user to

Re: Testing a Django library

2017-03-23 Thread Josh Crompton
There's no Django community standard of which I'm aware for doing this. There *is* a standard way to run tests for Python projects which use setuptools (which yours should do if you want people to be able to `pip install` it) [1]. I usually do something like this blog post describes [2]. Or,

Re: Testing a Django library

2017-03-22 Thread Jani Tiainen
Hi, Tox is quite neat test wrapper makes which easy to test code against multiple versions of Python and Django. On 21.03.2017 00:38, th...@copperleaf.com wrote: I am working on a Django library (which will be packaged) and want to set up testing for it. Looking at a number of existing

Re: Testing a Django library

2017-03-21 Thread Avraham Serour
What are the different approaches you found? I created a simple minimal project inside the tests folder On Mar 21, 2017 9:59 PM, "bobhaugen" wrote: > Very interesting topic. We will be facing the same problem soon, and will > hope to learn from your experience. Got a

Re: Testing a Django library

2017-03-21 Thread bobhaugen
Very interesting topic. We will be facing the same problem soon, and will hope to learn from your experience. Got a code repository yet? We're at https://github.com/django-rea If and when we have some good answers, I'll report back here. -- You received this message because you are subscribed

Re: Testing a reusable app which uses a database

2016-10-03 Thread Victor Porton
Well, I did it. On Monday, October 3, 2016 at 10:41:59 PM UTC+3, Victor Porton wrote: > > I try to make a reusable app which uses transaction.atomic(). > > When I run my test.py (below) for my reusable app, I get the below errors. > > Is it possible to test this reusable app outside of a Django

Re: Testing a reusable app which uses a database

2016-10-03 Thread Carl Meyer
On 10/03/2016 01:41 PM, Victor Porton wrote: > I try to make a reusable app which uses transaction.atomic(). > > When I run my test.py (below) for my reusable app, I get the below errors. > > Is it possible to test this reusable app outside of a Django project? It is not possible to test it

Re: Testing if a view have an html element with at least one attribute

2016-08-03 Thread Fred Stluka
Ludovic, On my project, we have lots of test cases that do a GET or POST and then check the returned HTML.  We use the BeautifulSoup HTML parser from our Django tests to avoid the types of errors you're getting with simple string comparisons.  I'm not sure if

Re: Testing an object

2016-08-01 Thread Neil Hunt
That was an silly basic python mistake. Doh! I just indented the method correctly and the test ran fine. Thanks a lot, ludovic :) On Monday, August 1, 2016 at 12:58:01 PM UTC+1, ludovic coues wrote: > > Look like you forget to indent the method inside your class. > > 2016-08-01 13:43 GMT+02:00

Re: Testing an object

2016-08-01 Thread ludovic coues
Look like you forget to indent the method inside your class. 2016-08-01 13:43 GMT+02:00 Neil Hunt : > I've read and reread the tutorial and I'm working on writing a very simple > banking app by copying and modifying what's in the tutorial. I've started a > new project and

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread Andreas Kuhne
Jupp, thats about what I meant :-) Probably the best way, if you don't want to check text. Regards, Andréas 2016-07-31 18:01 GMT+02:00 ludovic coues : > Currently, I am using lxml. More dependencies but it's the cleanest > method I've found currently. > I use it like that: >

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread ludovic coues
Currently, I am using lxml. More dependencies but it's the cleanest method I've found currently. I use it like that: from django.test import TestCase from lxml import etree class FormTest(TestCase): def test_input(self): response =

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread Andreas Kuhne
2016-07-31 15:59 GMT+02:00 ludovic coues : > Oh, sorry. A bit of misunderstanding and miscommunication on my part. > > The exemple I gave is just a quick way to reproduce my problem. The > real test use self.client, reverse, cast response.content to a string. > What I gave is a

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread ludovic coues
Oh, sorry. A bit of misunderstanding and miscommunication on my part. The exemple I gave is just a quick way to reproduce my problem. The real test use self.client, reverse, cast response.content to a string. What I gave is a minimal exemple. Also, I assumed you talked about comparing bit of

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread Andreas Kuhne
2016-07-31 13:56 GMT+02:00 ludovic coues : > First, thanks for the suggestion. > > I just tried that, didn't work. > Here is the test file I used: > > > from django.test import TestCase > > class HTMLTestCase(TestCase): > > def test_input_in_fieldset(self): >

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread ludovic coues
First, thanks for the suggestion. I just tried that, didn't work. Here is the test file I used: from django.test import TestCase class HTMLTestCase(TestCase): def test_input_in_fieldset(self): fieldset = """ """

Re: Testing if a view have an html element with at least one attribute

2016-07-31 Thread Andreas Kuhne
2016-07-31 12:38 GMT+02:00 ludovic coues : > Hello, > > I am trying to test if a view is displaying a form with an input > element with name=username. > > Currently, I have tried a lot of variation around > `self.assertContains( response, "", > html=True)` but none work. > I

Re: Testing the interaction of multiple sites

2016-01-04 Thread Nikolas Stevenson-Molnar
On Monday, January 4, 2016 at 3:39:22 PM UTC-8, Michal Petrucha wrote: > > Hi Nikolas, > > Thanks for your suggestion, unfortunately, I don't see how it helps in > my case. > > What I'm after is some kind of integration test: when I try to load a > page form the relying instance, verify that

Re: Testing the interaction of multiple sites

2016-01-04 Thread Michal Petrucha
On Mon, Jan 04, 2016 at 03:22:10PM -0800, Nikolas Stevenson-Molnar wrote: > HTTPretty may help with this. It will let you mock a response from the > second server: https://github.com/gabrielfalcao/httpretty > > _Nik Hi Nikolas, Thanks for your suggestion, unfortunately, I don't see how it

Re: Testing the interaction of multiple sites

2016-01-04 Thread Nikolas Stevenson-Molnar
HTTPretty may help with this. It will let you mock a response from the second server: https://github.com/gabrielfalcao/httpretty _Nik On Monday, January 4, 2016 at 2:50:05 PM UTC-8, Michal Petrucha wrote: > > Hi folks, > > I'd like to write some tests for a simple redirect-based SSO solution,

Re: Testing the interaction of multiple sites

2016-01-04 Thread Nikolas Stevenson-Molnar
HTTPretty may help with this. It will let you mock a response from the second server: https://github.com/gabrielfalcao/httpretty _Nik On 1/4/2016 2:49:34 PM, Michal Petrucha wrote: Hi folks, I'd like to write some tests for a simple redirect-based SSO solution,

Re: testing django migrations

2015-12-27 Thread Gergely Polonkai
I'm also interested in that, except that I'd like to test RunPython steps. On Dec 28, 2015 12:32 AM, "Dan Tagg" wrote: > Hi, > > I used this: > https://github.com/plumdog/django_migration_testcase > > It's only worth writing tests if you are modifying code created by

Re: testing django migrations

2015-12-27 Thread Dan Tagg
Hi, I used this: https://github.com/plumdog/django_migration_testcase It's only worth writing tests if you are modifying code created by makemigrations. Dan On 27 December 2015 at 10:14, varun naganathan wrote: > Hi,I wanted to know how am i supposed to test

Re: Testing related models without saving

2015-07-30 Thread Michael Herrmann
I'm very relieved - thanks Tim! If I can help, please let me know. Best, Michael On 30 July 2015 at 17:56, Tim Graham wrote: > We are working on that solution: > https://github.com/django/django/pull/5060 > > > On Thursday, July 30, 2015 at 7:19:31 AM UTC-4,

Re: Testing related models without saving

2015-07-30 Thread Tim Graham
We are working on that solution: https://github.com/django/django/pull/5060 On Thursday, July 30, 2015 at 7:19:31 AM UTC-4, mic...@herrmann.io wrote: > > Hi all, > > I've just been bitten by this new "feature" as well. I completely don't > understand this design decision of 1.8. It is very

Re: Testing related models without saving

2015-07-30 Thread michael
Hi all, I've just been bitten by this new "feature" as well. I completely don't understand this design decision of 1.8. It is very useful to be able to create model classes without having to save them to the database, not just for unit tests but also for experimenting in the shell. The new

Re: Testing related models without saving

2015-07-16 Thread Carl Meyer
Hi Roland, On 07/16/2015 07:46 AM, Roland Swingler wrote: >> i'll just say that Django tests don't favor too much into the "unit" > test spectrum; > > That is what I'm seeing - it is the same with rails out of the box as > well. I guess I'm just curious to know whether: > > a) the 'unit' test

Re: Testing related models without saving

2015-07-16 Thread Roland Swingler
> i'll just say that Django tests don't favor too much into the "unit" test spectrum; That is what I'm seeing - it is the same with rails out of the box as well. I guess I'm just curious to know whether: a) the 'unit' test end of the spectrum is feasible if that's what you like b) what is

Re: Testing related models without saving

2015-07-16 Thread Javier Guerra Giraldez
On Thu, Jul 16, 2015 at 8:18 AM, Roland Swingler wrote: > I understand that the test db uses a different schema (it's the same in > rails), the point is to be able to run tests isolated from having a database > at all. there are several testing styles, each one with

Re: Testing related models without saving

2015-07-16 Thread Roland Swingler
Hi, Thanks for the link - I'll investigate that further, especially as to whether you can set that dynamically. I understand that the test db uses a different schema (it's the same in rails), the point is to be able to run tests isolated from having a database at all. Thanks, Roland -- You

Re: Testing related models without saving

2015-07-16 Thread Bruno A.
This might help maybe: https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ForeignKey.allow_unsaved_instance_assignment On Thursday, 16 July 2015 12:21:30 UTC+1, Roland Swingler wrote: > > Hi all, > > I've very recently come to to Django from a rails background, and >

Re: Testing related models without saving

2015-07-16 Thread Bruno A.
You did not quote your models, but I assume your UserProfileDetails has a OneToOne or ForeignKey relationship with User model. With Django, you generally need to save the related model before adding it to the Foreignkey, as the relationship in UserProfileDetails is using the primary key

Re: Testing a new app

2015-05-28 Thread Bill Freeman
If the "new" app doesn't need services from the larger app in order t work, but rather the other way around, why not leave it separate, and later, just make it an install requirement for the larger app? On Thu, May 28, 2015 at 5:54 AM, Klaas Feenstra wrote: > Using GIT would

Re: Testing a new app

2015-05-28 Thread Klaas Feenstra
Using GIT would be the way of working.. On Thu, May 28, 2015 at 4:24 AM, DZ wrote: > Greetings, > > I want to start a new app that if it works out I will tie into a larger > django app. I do not really want the worlds to mix at the start just in > case I need scrap

Re: Testing Setup gives 500, but dev server works okay

2015-05-25 Thread Timothy W. Cook
I should add that the actual error is: selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"id_login"} because the main page never loads so it can't find the login button, On Mon, May 25, 2015 at 12:29 PM, Timothy W. Cook

Re: Testing request parameters in Django (“+” behaves differently)

2015-04-20 Thread Eneko Illarramendi
Thank you Tom. Somehow it seemed strange to test this view using client.get('/page/', { 'filter': 'one and two'}) but I get why it is like this. Cheers, Eneko On Monday, April 20, 2015 at 3:30:55 PM UTC+2, Tom Evans wrote: > > On Sat, Apr 18, 2015 at 12:13 PM, Eneko Illarramendi >

Re: Testing request parameters in Django (“+” behaves differently)

2015-04-20 Thread Tom Evans
On Sat, Apr 18, 2015 at 12:13 PM, Eneko Illarramendi wrote: > Previously posted in SO: > http://stackoverflow.com/questions/29703930/testing-request-parameters-in-django-behaves-differently > --- > > I have a Django View that uses a query

Re: Testing Django: testing template at different time

2015-03-18 Thread Zaki Akhmad
On Fri, Mar 13, 2015 at 5:32 AM, Collin Anderson wrote: > Hi, > > You could try using freezegun to run the test as if it were a certain time > of day. > https://pypi.python.org/pypi/freezegun Hi Collin, thanks for the response. After spent some time, finally I managed to

Re: Testing template context processors

2015-03-17 Thread Gergely Polonkai
Hello, My processor sets some template variables based on request.user and some DB/redis query results, which are displayed on each page on a header bar, so I only need to create a mocked request with user set to something (AnonymousUser or a valid user object). I'm already using Mock[2] for

Re: Testing template context processors

2015-03-17 Thread Carl Meyer
Hi Gergely, On 03/17/2015 10:52 AM, Gergely Polonkai wrote: > I wrote a context processor which makes some global variables of mine > available for templates. I cannot find a good (cough… any) article on > how to test such processors. Could you give me some directions on where > to start with

Re: Testing Django: testing template at different time

2015-03-12 Thread Collin Anderson
Hi, You could try using freezegun to run the test as if it were a certain time of day. https://pypi.python.org/pypi/freezegun Or, you could say something like: if 9 <= datetime.datetime.now().hour < 17: self.assertContains(response, "It's working time!") else:

Re: Testing posts to S3

2015-02-11 Thread Tom Evans
On Wed, Feb 11, 2015 at 7:36 PM, Lee Hinde wrote: > I'm using django storages/boto to push json files to s3 where they are to be > read by a different app. > > I'd like to test the file push by using the Test Client to see if the file > is present on S3. > > client = Client()

Re: Testing reusable application: compatible way

2014-12-07 Thread Carl Meyer
On 12/07/2014 12:59 PM, Matwey V. Kornilov wrote: > The following code works perfect for me, why the code in the > documentations so sophisticated? > > def runtests(): > os.environ.setdefault("DJANGO_SETTINGS_MODULE", > "tests.test_settings") > > try: > from

Re: Testing reusable application: compatible way

2014-12-07 Thread Carl Meyer
On 12/07/2014 02:28 PM, Carl Meyer wrote: > On 12/07/2014 08:40 AM, Matwey V. Kornilov wrote: >> I've followed this documentation: >> https://docs.djangoproject.com/en/1.7/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications >> and found that it works only for Django

Re: Testing reusable application: compatible way

2014-12-07 Thread Carl Meyer
Hi Matwey, On 12/07/2014 08:40 AM, Matwey V. Kornilov wrote: > I've followed this documentation: > https://docs.djangoproject.com/en/1.7/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications > and found that it works only for Django 1.7, whereas I would like to >

Re: Testing reusable application: compatible way

2014-12-07 Thread Matwey V. Kornilov
The following code works perfect for me, why the code in the documentations so sophisticated? def runtests(): os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.test_settings") try: from django import setup setup() except

Re: testing equality in template tag

2014-06-26 Thread Tom Evans
On Wed, Jun 25, 2014 at 7:34 PM, Lee Hinde wrote: > with view code like so: > > import calendar > months_choices = [] > for i in range(1,13): > months_choices.append((i, calendar.month_name[i])) > context['months'] = months_choices >

Re: testing equality in template tag

2014-06-26 Thread Roman Klesel
Ugh , sorry of course we know ... forget what i said ... 2014-06-26 9:48 GMT+02:00 Roman Klesel : > hard to tell since we do not know what values default_month and month.0 have > ... > try to print in the view and examine: > print type(month[0]), month[0],

Re: testing equality in template tag

2014-06-26 Thread Roman Klesel
hard to tell since we do not know what values default_month and month.0 have ... try to print in the view and examine: print type(month[0]), month[0], type(today.month), today.month 2014-06-25 20:34 GMT+02:00 Lee Hinde : > with view code like so: > > import calendar >

Re: Testing Frameworks and Practices(consensus?)

2013-12-12 Thread Arnold Krille
Am Wed, 11 Dec 2013 12:03:44 -0500 schrieb Thomas Murphy : > This seems like a more appropriate forum that SO for this discussion. > > I've been testing my apps with Selenium, which seems to be a popular > choice for Django, but so does unittest and some others, as

Re: Testing: @override_settings(AUTH_USER_MODEL='auth.User') no working.

2013-09-30 Thread Serge G. Spaolonzi
Thanks, it worked. Changing @override_settings(AUTH_USER_MODEL='auth.User') for @override_settings(AUTH_USER_MODEL='auth.CustomUser') made the trick. On Sun, Sep 29, 2013 at 9:09 PM, Russell Keith-Magee wrote: > > On Mon, Sep 30, 2013 at 7:27 AM, Serge G. Spaolonzi

Re: Testing: @override_settings(AUTH_USER_MODEL='auth.User') no working.

2013-09-29 Thread Russell Keith-Magee
On Mon, Sep 30, 2013 at 7:27 AM, Serge G. Spaolonzi wrote: > Hi, > > I am failing to override the AUTH_USER_MODEL settings for a unittest, it > throws: > > "Manager isn't available; User has been swapped for 'None'" > > Is it possible to override AUTH_USER_MODEL in the

Re: Testing in Django - newbie questions on first test failure and coverage

2013-09-23 Thread Derek
Hi Yes, you are right: deleting the _fixture_setup method allows the tests to run successfully! I also do have all my fixture data stored in 'appname/fixtures/initial_data.json' so I assume from what you say that this data will only be loaded once for all the tests. Once I have more

Re: Testing in Django - newbie questions on first test failure and coverage

2013-09-23 Thread Derek
Hi Rafael Yes, you are right: deleting the _fixture_setup method allows the tests to run successfully! I also do have all my fixture data stored in 'appname/fixtures/initial_data.json' so I assume from what you say that this data will only be loaded once for all the tests. Once I have more

Re: Testing in Django - newbie questions on first test failure and coverage

2013-09-22 Thread Rafael Durán Castañeda
Hi, El 21/09/2013, a las 13:36, Derek escribió: > Rafael > > I appreciate your reply; below I try and explain further the reasoning behind > the approach I took. If you can respond to that, it would help. > > > Firstly, the issue of test file locations - there are

Re: Testing in Django - newbie questions on first test failure and coverage

2013-09-21 Thread Derek
Rafael I appreciate your reply; below I try and explain further the reasoning behind the approach I took. If you can respond to that, it would help. Firstly, the issue of test file locations - there are least two places I have found that recommend these be placed in a different directory:

Re: Testing in Django - newbie questions on first test failure and coverage

2013-09-16 Thread Rafael Durán Castañeda
Hi, Some answers inline and links at the end: 2013/9/15 Derek > I have an existing Django (1.4) project, with multiple apps and extensive > business logic, that I need to write tests for. Based on a day or two of > reading of the core Django docs and numerous blogs (each

Re: Testing Permissions in URL Includes

2013-09-13 Thread Lee Hinde
On Sep 13, 2013, at 12:47 PM, Arnold Krille wrote: > On Fri, 13 Sep 2013 11:30:44 -0700 Lee Hinde wrote: >> So, the question, is there a way to wrap url include calls in a >> permission check? > > Wrapping a whole url-include would only work when the

Re: Testing Permissions in URL Includes

2013-09-13 Thread Arnold Krille
On Fri, 13 Sep 2013 11:30:44 -0700 Lee Hinde wrote: > So, the question, is there a way to wrap url include calls in a > permission check? Wrapping a whole url-include would only work when the url-tree is rebuild for each request taking into account the requesting user. Todays

Re: Testing with legacy data

2013-08-06 Thread Tom Evans
On Tue, Aug 6, 2013 at 5:59 AM, Jani Tiainen wrote: > Hi, > > I've legacy database that is rather large (around 300MB) containing lot more > than just data (triggers, stored procedures and such). > > Now how I can test with such a data? Preferably I would like to load data to

Re: Testing django views: RequestFactory and CSRF protection

2013-07-20 Thread Vladimir Ignatev
Well, looks like I've found workaround. At first we should test if a view have CSRF protection: def test_csrf_protected(self): request = RequestFactory().post('', data={}) response = views.register_form(request) self.assertEqual(response.status_code, 403) (fix me, it is

  1   2   3   >