[Solved]: Unit testing migrations [Was: Related model 'company.user' cannot be resolved]

2021-07-07 Thread Mike Dewhirst
place and importing them into the company app but things quickly got messy. Much easier to bite the bullet and just physically move the files. [3] At this point the software should work but unit testing will fail because the test database is always generated from the sum total of all migrations

Unit testing migrations [Was: Related model 'company.user' cannot be resolved]

2021-07-06 Thread Mike Dewhirst
It seems I have to meddle with history and persuade the testing harness that my custom user model has been in the company app from the beginning of time. See story below. Upside is that testing will (might) start working again. Downside is I'll go mad. Any ideas? Thanks Mike On 6/07/2021

Django reverse lookup fails during unit testing

2021-03-16 Thread Derek
Hi When I open the Django shell (python manage.py shell) and test a reverse URL: >>> from django.urls import reverse >>> reverse('admin:locales_site_changelist') '/admin/locales/site/' then it works as expected. However, when I try and use the same lookup string via a unit test: from django.te

Re: Hello ! I'm having some issues in django unit testing. Is there anybody to help ?

2020-11-06 Thread Monaco investment
:59 PM To: Django users Subject: Hello ! I'm having some issues in django unit testing. Is there anybody to help ? Hello ! I'm having some issues in django unit testing. Is there anybody to help ? I'm having confusion in testing django mixins . Can anyone share his/her git with

Hello ! I'm having some issues in django unit testing. Is there anybody to help ?

2020-11-06 Thread Nilima Dahal
Hello ! I'm having some issues in django unit testing. Is there anybody to help ? I'm having confusion in testing django mixins . Can anyone share his/her git with such unit testing or have some experienced shareable codes. how do I test this ? def dispatch(self,request,*arg

Re: Unit Testing POST request

2020-02-13 Thread onlinejudge95
On Thu, Feb 13, 2020 at 8:14 PM sachinbg sachin wrote: > Fistly for setup create use instance for setup user credentials then call > that the reverse url in that post put delite > I have already created my test users in the *setUpClass()* method. As mentioned my problem was not something related

Re: Unit Testing POST request

2020-02-13 Thread onlinejudge95
On Thu, Feb 13, 2020 at 8:02 PM Adam Mičuda wrote: > Hi, > or you can extract the business logic from view to some service and unit > test it instead. =) > I am following the same, it's just that I am also performing serialization as of now in my views, since I want to push it out first, and hav

Re: Unit Testing POST request

2020-02-13 Thread sachinbg sachin
Fistly for setup create use instance for setup user credentials then call that the reverse url in that post put delite On Thu, Feb 13, 2020, 8:01 PM Adam Mičuda wrote: > Hi, > or you can extract the business logic from view to some service and unit > test it instead. =) > > Regards. > > Adam > >

Re: Unit Testing POST request

2020-02-13 Thread Adam Mičuda
Hi, or you can extract the business logic from view to some service and unit test it instead. =) Regards. Adam st 12. 2. 2020 v 21:15 odesílatel onlinejudge95 napsal: > On Wed, Feb 12, 2020 at 6:22 PM onlinejudge95 > wrote: > >> Hi Devs, >> >> I was implementing unit-tests in my Django projec

Re: Unit Testing POST request

2020-02-12 Thread onlinejudge95
On Wed, Feb 12, 2020 at 6:22 PM onlinejudge95 wrote: > Hi Devs, > > I was implementing unit-tests in my Django project and stumbled upon the > following issue. > > I want to unit-test my POST route. I do not want to use the test client > already shipped with Django (using it in my e2e tests). I w

Re: Unit Testing POST request

2020-02-12 Thread onlinejudge95
Hi Guys, Any leads would be appreciated On Wed, Feb 12, 2020 at 6:22 PM onlinejudge95 wrote: > Hi Devs, > > I was implementing unit-tests in my Django project and stumbled upon the > following issue. > > I want to unit-test my POST route. I do not want to use the test client > already shipped

Unit Testing POST request

2020-02-12 Thread onlinejudge95
Hi Devs, I was implementing unit-tests in my Django project and stumbled upon the following issue. I want to unit-test my POST route. I do not want to use the test client already shipped with Django (using it in my e2e tests). I want to know how do I prepare my request object to pass to my view.

Re: Unit-Testing Django Views

2019-03-30 Thread Jorge Gimeno
The online version of the book is pinned to Django 1.11. You may want to check that out. -Jorge On Sat, Mar 30, 2019 at 4:40 AM Test Bot wrote: > Sorry for the bother but I finally solved it by using Django's Test Client > and checking for status_code and template used to render the response in

Re: Unit-Testing Django Views

2019-03-30 Thread Test Bot
Sorry for the bother but I finally solved it by using Django's Test Client and checking for status_code and template used to render the response in my unit-test. Regards, Test Bot On Sat, Mar 30, 2019 at 5:00 PM Test Bot wrote: > I tried removing the {% csrf_token %} from my index.html But it s

Re: Unit-Testing Django Views

2019-03-30 Thread Test Bot
I tried removing the {% csrf_token %} from my index.html But it seemed to have no effect. I got the following traceback for further clarity * START OF TRACEBACK*

Re: Unit-Testing Django Views

2019-03-30 Thread Test Bot
Thanks everyone for the clearance of the problem. I will remove the unit test's logic to check fir template, it seems a viable test case along with the status code value. On Fri, Mar 29, 2019, 2:24 AM Chetan Ganji wrote: > There is one more way you could do it > > > class TestIndexPageLoad(TestC

Re: Unit-Testing Django Views

2019-03-28 Thread Chetan Ganji
There is one more way you could do it class TestIndexPageLoad(TestCase): def setUp(self): self.client = Client() self.response = self.client.get('/') def test_check_response(self): self.assertTemplateUsed(self.response, 'index.html') Regards, Chetan Ganji +91-900-483-4183 ganji.che...@gmail.

Re: Unit-Testing Django Views

2019-03-28 Thread Chetan Ganji
I would prefer to just check the status code of the response object. This is what I have done. You have to check if it works for forms with csrf_token or not. class TestReverseUrls(TestCase): def setUp(self): self.client = Client() self.reverseUrls = ['index', 'login', 'register'] self.response

Re: Unit-Testing Django Views

2019-03-28 Thread Aldian Fazrihady
There are several things you can try: 1. Mocking csrf token functions 2. Passing the csrf token context from first HTML generation to the second HTML generation 3. Wiping out the csrf token parts from both HTML before comparing them. On Thu, 28 Mar 2019, 23:54 Simon Charette, wrote: > This is ef

Re: Unit-Testing Django Views

2019-03-28 Thread Simon Charette
This is effectively failing because of a mechanism added in 1.10 to protect against BREACH attacks[0] by salting the CSRF token. I'm not aware of any way to disable this mechanism but testing against the exact HTML returned from a view seems fragile. I suggest you use assertContains[1] (with or w

Unit-Testing Django Views

2019-03-28 Thread OnlineJudge95
Hi people, I am following the book Test-Driven Development with Python by *Harry J.W. Perceval.* The book is using Django version 1.7 which is outdated as of now so I started with version 2.1. I am trying

Re: Django unit testing and pk's changing

2018-10-24 Thread David
The issue was my using incorrect def get_absolute_url's in my model My error. On Wednesday, 24 October 2018 12:24:07 UTC+1, David wrote: > > Hi > > When I run tests on my app they run through fine. > > When I run tests just using "manage.py test" the app mentioned above > contains failures.

Django unit testing and pk's changing

2018-10-24 Thread David
Hi When I run tests on my app they run through fine. When I run tests just using "manage.py test" the app mentioned above contains failures. Example code: def test_lumpsum_get_absolute_url(self): lumpsum = LumpSum.objects.get() self.assertEquals(lumpsum.get_absolute_url(),

Re: Unit testing models.py

2018-05-14 Thread Melvyn Sopacua
Hi Mark, On zondag 13 mei 2018 18:11:07 CEST Mark Phillips wrote: > What should be unit tested in models.py? I assume the storing of data and > retrieving of data from the database does not need to be tested, as I > further assume django has a full set of tests for those operations. You should te

Re: Unit testing models.py

2018-05-13 Thread 'Anthony Flury' via Django users
I would agree with that - test any custom functionality - * Custom methods (including __str__ and __repr__) * custom managers * Triggers (that maybe save custom fields on update) * validations - testing to ensure that the right validation is performed on that field - i.e. you linked the ri

Re: Unit testing models.py

2018-05-13 Thread Jani Tiainen
Hi, In general you don't need to test your models if you don't use anything special there. If you do have properties or methods on models that do something that is good to test that they return correct values or do correct things. On Sun, May 13, 2018 at 7:11 PM, Mark Phillips wrote: > What s

Unit testing models.py

2018-05-13 Thread Mark Phillips
What should be unit tested in models.py? I assume the storing of data and retrieving of data from the database does not need to be tested, as I further assume django has a full set of tests for those operations. I can see testing these parts of models.py * All custom methods * Labels for all fie

Re: Unit testing Multiselect fields not loading as expected

2017-05-08 Thread Trevor Woolley
Thanks Tim. On Mon, May 8, 2017 at 8:49 PM, Tim Graham wrote: > This is because you have a module level query at my_choices = [(m['id'], > m['displayname']) for m in get_my_list()]. > > There's a documentation warning about this; see the "Finding data from > your production database when running

Re: Unit testing Multiselect fields not loading as expected

2017-05-08 Thread Tim Graham
This is because you have a module level query at my_choices = [(m['id'], m['displayname']) for m in get_my_list()]. There's a documentation warning about this; see the "Finding data from your production database when running tests?" note in ​this section [0]. [0] https://docs.djangoproject.c

Re: Unit testing Multiselect fields not loading as expected

2017-05-07 Thread Trevor Woolley
Further investigation shows this as failing outside of a test scenario, and the "my_choices" is not being updated, unless the server (be that the ./manage.py runserver" or a production apache server) is restarted. Rgds Trevor On Friday, May 5, 2017 at 3:20:04 PM UTC+10, Trevor Woolley wrote: >

Unit testing Multiselect fields not loading as expected

2017-05-04 Thread Trevor Woolley
Hi, when I run a unittest on a form containing a MultipleChoiceField, and in the unittest I test setting what I think should be a valid field, it does not pass. It appears that field in question extracts the data is uses for the test before the test database is created, and actually uses the pr

Re: Unit testing in django for django template

2016-10-12 Thread ludovic coues
('.//input[@name="password"]')), 1) You'll need to install the package lxml for the import to work 2016-10-12 22:23 GMT+02:00 James Schneider : > In general, you would request the page and inspect the rendered output. > > https://docs.djangoproject.com/en/1.

Re: Unit testing in django for django template

2016-10-12 Thread James Schneider
In general, you would request the page and inspect the rendered output. https://docs.djangoproject.com/en/1.10/topics/testing/tools/#testing-responses -James On Wed, Oct 12, 2016 at 12:17 PM, wrote: > How to Unit testing in django for django template > > please any on

Unit testing in django for django template

2016-10-12 Thread codemaster472
How to Unit testing in django for django template please any one help me??? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-user

How do you approach unit testing for pluggable apps?

2015-12-21 Thread Nan
So far I usually just build a sample project that also serves as a demonstration of how to use the pluggable app, and use `manage.py test` to run the tests inside the pluggable apps test module. Is this the preferred method? Should a pluggable app's tests stand alone and be runnable outside o

Re: Unit testing for apis

2015-11-24 Thread David Palao
n Mehta : > Hi All, > > How can I write negative unit test cases for api endpoints > I am using django.tests.TestCase for unit testing. > > Thanks, > Kishan > > -- > You received this message because you are subscribed to the Google Groups > "Django users" grou

Unit testing for apis

2015-11-24 Thread Kishan Mehta
Hi All, How can I write negative unit test cases for api endpoints I am using django.tests.TestCase for unit testing. Thanks, Kishan -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiv

Re: Unit-testing Custom Admin Action, requires request and querysets parameters.

2014-11-25 Thread Azam Alias
Hi Collin, I apologise for the late update. Didnt get any notifications from your reply. I have solved this issue as per your suggestion. Pasting the solution for others' reference. Thanks ! from django.test import TestCase from django.contrib.admin.sites import AdminSite from batch_apps.mod

Re: Unit-testing Custom Admin Action, requires request and querysets parameters.

2014-11-05 Thread Collin Anderson
Hello, Would it work to import AppAdmin, instantiate it, and then call the methods in a unit test? Collin -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to dj

Unit-testing Custom Admin Action, requires request and querysets parameters.

2014-11-02 Thread Azam Alias
Hi, I would like to unit-test the activate_apps( ) and deactivate_apps( ) functions below, as low-level as possible. How could I do this without going through Selenium (FT) route? In my admin.py: from django.contrib import admin from my_app_listing.models import App class AppAdmin(admin.Mode

Re: Unit testing - self.assertEqual("Break it!", resp.content)

2014-07-06 Thread Pepsodent Cola
Hi, I have been using assertEqual lately in my unit testing to deliberately make coverage break. By comparing *Something False* with the complete HTML returned (*resp.content*). self.assertEqual("Something False", *resp.content*) In order to reveal and debug the

Re: Unit testing - self.assertEqual("Break it!", resp.content)

2014-07-06 Thread Mitesh Patel
Hi, You are trying to compare break it! with the complete HTML returned. Instead of assertEqual, use assertIn. self.assertIn("Break it!", resp.content) Regards, Mitesh On 7 Jul 2014 01:44, "Pepsodent Cola" wrote: > When I run this unit test to make it break so it can output a bunch of > html

Unit testing - self.assertEqual("Break it!", resp.content)

2014-07-06 Thread Pepsodent Cola
When I run this unit test to make it break so it can output a bunch of html data. self.assertEqual("Break it!", *resp.content*) test.py # Reset password no login def test_Reset_no_login(self): self.assertTrue(isinstance(self.user, User)) login = self.client.login(username='captain'

Unit testing - return HttpResponseRedirect('/accounts/loggedin')

2014-07-04 Thread Pepsodent Cola
Hi coverage has highlighted that I have no unit test for the line, regarding *HttpResponseRedirect('/accounts/loggedin')*. How can I write a test that makes Coverage happy regarding this? views.py def auth_view(request): username = request.POST.get('username', '') password = request.P

Re: Unit testing - self.assertEqual(login, True)

2014-07-03 Thread Pepsodent Cola
Thanks! I see what I did wrong now. class UserProfileTest(TestCase): # Create User def setUp(self): self.user = *User.objects.create_user*(username='captain', password='america') # Logged in def test_VIEW_USER__Logged_in(self): self.assertTrue(isinstance(self.us

Re: Unit testing - self.assertEqual(login, True)

2014-07-03 Thread Amim Knabben
duplicated question https://groups.google.com/forum/#!topic/django-users/I4wmYKNMNn8 On Thu, Jul 3, 2014 at 9:09 AM, Pepsodent Cola wrote: > I want to run a unit test for a user logging in but I get error. What am > I doing wrong? > > > from django.test import TestCase > from userprofile.mode

Unit testing - self.assertEqual(login, True)

2014-07-03 Thread Pepsodent Cola
I want to run a unit test for a user logging in but I get error. What am I doing wrong? from django.test import TestCase from userprofile.models import UserProfile from django.contrib.auth.models import User class UserProfileTest(TestCase): # User factory method def create_user(self, u

Re: unit testing

2013-07-09 Thread ben
Also note that Django 1.6 will bring a better test discovery mechanism. See the full details at https://docs.djangoproject.com/en/dev/releases/1.6/#discovery-of-tests-in-any-test-module Django 1.6 ships with a new test runner that allows more flexibility in the > location of tests. The previous

Re: unit testing

2013-07-08 Thread Larry Martell
On Mon, Jul 8, 2013 at 9:36 AM, Javier Guerra Giraldez wrote: > On Mon, Jul 8, 2013 at 10:13 AM, Larry Martell > wrote: >> I had seen the __init__ but I thought the tests had to be in the same >> dir as the models file. > > > the tests _module_ has to be in the same dir as the models module. > t

Re: unit testing

2013-07-08 Thread Javier Guerra Giraldez
On Mon, Jul 8, 2013 at 10:13 AM, Larry Martell wrote: > I had seen the __init__ but I thought the tests had to be in the same > dir as the models file. the tests _module_ has to be in the same dir as the models module. that means either a tests.py file, or a tests directory with an __init__.py f

Re: unit testing

2013-07-08 Thread Larry Martell
On Mon, Jul 8, 2013 at 8:59 AM, wrote: > > > On Monday, July 8, 2013 7:49:53 AM UTC-4, larry@gmail.com wrote: >> >> >> >> Ah, I missed that in the docs. Thanks. When I renamed it to tests.py >> it got picked up. >> >> But in the django/contrib dirs (e.g. django/contrib/auth) the tests >> are

Re: unit testing

2013-07-08 Thread ben
On Monday, July 8, 2013 7:49:53 AM UTC-4, larry@gmail.com wrote: > > > > Ah, I missed that in the docs. Thanks. When I renamed it to tests.py > it got picked up. > > But in the django/contrib dirs (e.g. django/contrib/auth) the tests > are in a tests sub dir and are not called tests.py and

Re: unit testing

2013-07-08 Thread Larry Martell
On Sun, Jul 7, 2013 at 10:05 PM, Javier Guerra Giraldez wrote: > On Sun, Jul 7, 2013 at 10:47 PM, Larry Martell > wrote: >> MeasDataTest is declared as: >> >> class MeasDataTest(TestCase): >> >> Why do I get "does not refer to a test"? > > where do you define your test? AFAIR, it must be either

Re: unit testing

2013-07-07 Thread Javier Guerra Giraldez
On Sun, Jul 7, 2013 at 10:47 PM, Larry Martell wrote: > MeasDataTest is declared as: > > class MeasDataTest(TestCase): > > Why do I get "does not refer to a test"? where do you define your test? AFAIR, it must be either in the models.py, or a tests.py file in the same directory. > Then I tried

Re: unit testing

2013-07-07 Thread Larry Martell
On Sun, Jul 7, 2013 at 7:22 PM, Larry Martell wrote: > Just getting started with django unit testing. I created a very simple > test, just to see how things work. Here is my test: > > from django.test import TestCase > > fixtures = ['auth_user', 'auth_p

unit testing

2013-07-07 Thread Larry Martell
Just getting started with django unit testing. I created a very simple test, just to see how things work. Here is my test: from django.test import TestCase fixtures = ['auth_user', 'auth_permission', 'data_cst'] class MeasDataTest(TestCase): def test_M

Re: Error with unit testing with Raven.

2012-12-14 Thread xina towner
I've found the solution. The problem was that I was using the 'raven.contrib.django.middleware.Sentry404CatchMiddleware' so the Middleware was getting the 404 signals. I think that because of that the test were not receiving the signals so when in the test we were checking for 404 codes the tests w

Error with unit testing with Raven.

2012-12-13 Thread xina towner
Hi, I'm trying to use Raven in order to send messages to my CI server. I had some tests that pass but suddenly they are failing. Does anyone knows why is that? Output: == ERROR: test_not_individual (quests.tests.views.TaskDoTest

Re: Keep getting TemplateDoesNotExist when unit testing

2012-03-03 Thread Calvin Cheng
: > > Hello, > > I'm fairly new to Unit Testing. > > As I'm trying to setup a simple unit test in one of my Projects, > it keeps returning a TemplateDoesNotExist Exception. > > It looks like for some reason the unit test framework can't locate my > template di

Keep getting TemplateDoesNotExist when unit testing

2011-12-24 Thread Jonas Geiregat
Hello, I'm fairly new to Unit Testing. As I'm trying to setup a simple unit test in one of my Projects, it keeps returning a TemplateDoesNotExist Exception. It looks like for some reason the unit test framework can't locate my template directory I've correctly defined in

Keep getting TemplateDoesNotExist when unit testing

2011-12-24 Thread Jonas Geiregat
Hello, I'm fairly new to Unit Testing. As I'm trying to setup a simple unit test in one of my Projects, it keeps returning a TemplateDoesNotExist Exception. It looks like for some reason the unit test framework can't locate my template directory I've correctly defined in

Re: Import error when unit testing with django.test.client on django 1.1.1

2011-11-24 Thread Erlendur Hákonarson
Thanks Xavier I will research this better but the path for the settings file is wrong in this error, it should be 'bo.settings' not 'DER.settings' but that might be because the tests do not have my project in their path Thanks again Erlendur -- You received this message because you are subscrib

Re: Import error when unit testing with django.test.client on django 1.1.1

2011-11-23 Thread xordoquy
Hi The error is: > ImportError: Could not import settings 'DER.settings' (Is it on > sys.path? Does it have syntax errors?): No module named DER.settings > ERROR: Module: Test could not be imported (file: > C:TFSSrc_BranchDER_UnitTestingboteststestListsTest.py). You should google a bit on how to

Import error when unit testing with django.test.client on django 1.1.1

2011-11-23 Thread Erlendur Hákonarson
I am trying to set up unit tests on my project but when I try to import anything from f.e. django.test then I get this error: Traceback (most recent call last): File "C:\eclipse\plugins\org.python.pydev.debug_2.2.2.2011082312\pysrc\pydev_runfiles.py", line 307, in __get_module_from_str mod

Re: Unit-Testing Dilemma

2011-06-22 Thread Nan
> Use Mock and assert_called_with: > http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock.assert_ca... > In this case you'd set theAPI.call as your mock and check that under > different conditions it is called correctly. Oh, perfect -- thank you, that will help a lot! > You don't need mo

Re: Unit-Testing Dilemma

2011-06-21 Thread Andrew Brookins
You don't need mocks or dependency injection in this case. Just separate the message construction code, so you can test it in isolation: # myapp.views from django.http import HttpResponse from myapp.models import CurrentState from myapp.exceptions import ApiFailureException from third_party.api i

Re: Unit-Testing Dilemma

2011-06-21 Thread Andy McKay
On 2011-06-20, at 12:52 PM, Nan wrote: > I'm not testing the third-party service. I need to test *what I send > to them*. Use Mock and assert_called_with: http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock.assert_called_with In this case you'd set theAPI.call as your mock and check

Re: Unit-Testing Dilemma

2011-06-21 Thread Nan
> That's what I was suggesting; that way the view becomes simple enough that > anyone looking at it can be assured of its correctness, without a host of > unit tests. Those tests can be applied to the functions that actually > construct the messages. Right, it's really those supporting functions

Re: Unit-Testing Dilemma

2011-06-21 Thread Ian Clelland
3rd-party API as imported > at > > the top of the file. > > I'd be a little confused as to how to factor that out. I mean, in the > actual app that call is refactored behind a function that wraps the > third-party API, and I could theoretically monkey-patch something o

Re: Unit-Testing Dilemma

2011-06-21 Thread Nan
onfused as to how to factor that out. I mean, in the actual app that call is refactored behind a function that wraps the third-party API, and I could theoretically monkey-patch something over that function call for unit testing. But the view still has to return an HttpResponse, and a blank one. &

Re: Unit-Testing Dilemma

2011-06-20 Thread Ian Clelland
gt; Just brainstorming here, could there be a way around this by placing a > logging call of some sort in theAPI.call() that would only be executed > during unit testing, and then to test the contents of the log? > This sounds like turning your API wrapper into a mock object at test time -

Re: Unit-Testing Dilemma

2011-06-20 Thread Nan
orrectness of their logic. Just brainstorming here, could there be a way around this by placing a logging call of some sort in theAPI.call() that would only be executed during unit testing, and then to test the contents of the log? On Jun 20, 6:20 pm, DrBloodmoney wrote: > On Mon, Jun 20,

Re: Unit-Testing Dilemma

2011-06-20 Thread DrBloodmoney
On Mon, Jun 20, 2011 at 3:52 PM, Nan wrote: > I'm not testing the third-party service.  I need to test *what I send > to them*.  I.e. that the output of my_view is correct.  The trouble is > that neither my_view nor the API call actually returns the output that > I need to check. > > Does that mak

Re: Unit-Testing Dilemma

2011-06-20 Thread Nan
I'm not testing the third-party service. I need to test *what I send to them*. I.e. that the output of my_view is correct. The trouble is that neither my_view nor the API call actually returns the output that I need to check. Does that make sense? On Jun 20, 1:59 pm, Daniel Roseman wrote: >

Re: Unit-Testing Dilemma

2011-06-20 Thread Daniel Roseman
On Monday, June 20, 2011 6:07:59 PM UTC+1, Nan wrote: > > In most situations, my app, upon receiving an HTTP request, sends data > to a third-party API, and returns an empty HttpResponse. I need to > test that the correct data is sent to the third-party API based on > internal application state

Unit-Testing Dilemma

2011-06-20 Thread Nan
In most situations, my app, upon receiving an HTTP request, sends data to a third-party API, and returns an empty HttpResponse. I need to test that the correct data is sent to the third-party API based on internal application state. I'm perplexed as to how to intercept this data in a unit test.

Re: unit testing and file location

2011-05-11 Thread Calvin Spealman
You can run your tests with their own --settings parameter with the specific variations you want to test under. On May 10, 2011 5:21 PM, "Brian Craft" wrote: I would like unit tests that do file manipulations to run with a different storage "location", so they're not manipulating real app files.

unit testing and file location

2011-05-10 Thread Brian Craft
I would like unit tests that do file manipulations to run with a different storage "location", so they're not manipulating real app files. Is there a good way to do this? Is there a way to override model field initializers, so I can instance a model, passing in the 'storage' parameter for an ImageF

Re: Unit Testing: temporarily altering django settings

2011-02-21 Thread Phlip
On Feb 21, 12:47 pm, Cody Django wrote: > Thanks -- I didn't know about mock objects, and this is good to know. > But this doesn't feel like this is the solution I'm looking for.  It's > a large project, and your proposal would require extensive patching. Does your project access the CAPTCHA set

Re: Unit Testing: temporarily altering django settings

2011-02-21 Thread Mikhail Korobov
Why doesn't setattr work? Just make sure you're setting the proper option because apps often cache options at e.g. their 'config.py' file in order to provide default values: # captha_app/config.py from django.conf import settings CAPTCHA = getattr(settings, 'CAPTCHA', True) So you'll have to chan

Re: Unit Testing: temporarily altering django settings

2011-02-21 Thread Cody Django
Thanks -- I didn't know about mock objects, and this is good to know. But this doesn't feel like this is the solution I'm looking for. It's a large project, and your proposal would require extensive patching. Is the solution to create a new testrunner that sets a different environment (with diffe

Re: Unit Testing: temporarily altering django settings

2011-02-17 Thread Phlip
On Feb 17, 12:03 pm, Cody Django wrote: > For example, I have a captcha that is used in parts of a site that > affects form logic. > The django settings has a variable CAPTCHA = True, which acts as a > switch. > > I'd like to change this setting in the setup for each TestCase. You should use a m

Unit Testing: temporarily altering django settings

2011-02-17 Thread Cody Django
For example, I have a captcha that is used in parts of a site that affects form logic. The django settings has a variable CAPTCHA = True, which acts as a switch. I'd like to change this setting in the setup for each TestCase. The regular unittests tests (in which we are assuming the captcha is of

Re: Unit testing in django without using test client

2010-09-17 Thread Paul Winkler
On Fri, Sep 17, 2010 at 10:58:19AM +0530, girish shabadimath wrote: > hi Paul, > > thanks for d reply,,,but im new to python n django,,,dint do ne python unit > testing before,,can u plz give me some links or hints to start with... http://docs.djangoproject.com/en/1.2/topics/testing/

Re: Unit testing in django without using test client

2010-09-17 Thread Paul Winkler
On Fri, Sep 17, 2010 at 10:58:19AM +0530, girish shabadimath wrote: > hi Paul, > > thanks for d reply,,,but im new to python n django,,,dint do ne python unit > testing before,,can u plz give me some links or hints to start with... http://docs.djangoproject.com/en/1.2/topics/testing/

Re: Unit testing in django without using test client

2010-09-17 Thread Carlton Gibson
Hi Girish, On 17 Sep 2010, at 06:28, girish shabadimath wrote: > thanks for d reply,,,but im new to python n django,,,dint do ne python unit > testing before,,can u plz give me some links or hints to start with... IN that case I'd recommend this book: http://www.amazon.com/Dja

Re: Unit testing in django without using test client

2010-09-16 Thread girish shabadimath
hi Paul, thanks for d reply,,,but im new to python n django,,,dint do ne python unit testing before,,can u plz give me some links or hints to start with... On Thu, Sep 16, 2010 at 8:09 PM, Paul Winkler wrote: > On Sep 16, 10:11 am, girish shabadimath > wrote: > > than

Re: unit testing and not creating database for read only database

2010-09-16 Thread keith
created http://code.djangoproject.com/ticket/14296 On Sep 16, 4:22 pm, keith wrote: > I have the same problem, have you logged a ticket for this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...

Re: unit testing and not creating database for read only database

2010-09-16 Thread keith
I have the same problem, have you logged a ticket for this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr.

Re: Unit testing in django without using test client

2010-09-16 Thread Paul Winkler
On Sep 16, 10:11 am, girish shabadimath wrote: > thanks for reply, > actually i used unit test to test urls and other view functions,,,there is a > module called Client() in django which acts as a browser to test urls,,, > > my problem is ,i want to test other methods in my project,,, how to do >

Re: Unit testing in django without using test client

2010-09-16 Thread girish shabadimath
thanks for reply, actually i used unit test to test urls and other view functions,,,there is a module called Client() in django which acts as a browser to test urls,,, my problem is ,i want to test other methods in my project,,, how to do so, without making use of django's test client..?.. O

Re: Unit testing in django without using test client

2010-09-16 Thread Shawn Milochik
You can use Python's unittest module to test any Python code (including Django code). What is it about Django's test client or TestCase class that is a problem for you? Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this gr

Unit testing in django without using test client

2010-09-16 Thread girish shabadimath
hi,,, i need to do unit testing in one of d django project, is there any other way to test functions ( or methods ) without using test client..? -- Girish M S -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Django --Unit testing view functions

2010-09-06 Thread girish shabadimath
hi,,, anybody help me with testing django views,,, * wat all things need to be tested for view functions..? * little bit confused about d usage of these two-- self.failUnlessEquals(XXX, XXX) and self.assertEquals(XXX, XXX) both seems to be same for me,, * any related books or links is appreciat

Re: defining models for unit testing only

2010-08-22 Thread Atamert Ölçgen
Hi, > I wrote a django 'app', thats basically just a class that takes a > Queryset, some other information, and then outputs an HttpResponse > object (it does some other things too). How do I write unit tests for > this class? The app itself does not contain any models, yet the > functionality of

defining models for unit testing only

2010-08-21 Thread mack the finger
I wrote a django 'app', thats basically just a class that takes a Queryset, some other information, and then outputs an HttpResponse object (it does some other things too). How do I write unit tests for this class? The app itself does not contain any models, yet the functionality of the class depen

Re: unit testing and not creating database for read only database

2010-07-29 Thread thusjanthan
Any suggestions? On Jul 7, 2:21 pm, thusjanthan wrote: > Hi, > > So I have a read only database called "information" which has been > modeled in the django framework with the managed=false for the META on > all its tables. When I run unit tests on another app I do not want the > unit tests to go

unit testing and not creating database for read only database

2010-07-07 Thread thusjanthan
Hi, So I have a read only database called "information" which has been modeled in the django framework with the managed=false for the META on all its tables. When I run unit tests on another app I do not want the unit tests to go and create a test database for "information" but would rather like t

Problem with queryset during model unit-testing

2010-02-12 Thread Alexey
First, the code of my tests.py def test_get_current(self): m = Member.objects.create(...) q = Question.objects.create(name="q1", text="q1", start_datetime=self.day_before, close_datetime=self.day_after, type=self.type) r = Response.objects.create(question=q, text='response') expect

Re: Unit testing Templatetags

2010-02-07 Thread Jari Pennanen
> here:http://github.com/darkrho/django-dummyimage/blob/master/dummyimage/te... Great example. IMO, there should be more unit-testing examples in Django documentation, templatetags should be one... -- You received this message because you are subscribed to the Google Groups "Django users" gr

  1   2   >