The problem is not where I start the worker. You are absolutely right, i can start in the setup code as well and am fine with doign that.
My problem, is wherever I start the work process, how do I get the work process, which tries to access the data model, to talk to the "test" database. When I start the work process it automatically talks to the "default" database, not the test database, that was created/connected to by the django testing code. On Monday, June 26, 2017 at 9:42:50 AM UTC-7, Avraham Serour wrote: > > I don't think you need to create a custom TestRunner, I believe it would > be enough to use setUp and tearDown to start and stop an external process, > which in your case would be a celery worker > > Would that work for you? > > On Mon, Jun 26, 2017 at 6:19 PM, sarvi <[email protected] <javascript:>> > wrote: > >> anybody have any suggestions on how I can do this? >> >> >> I essentially want a worker process to connect to the django test >> database ? >> >> >> On Thursday, June 22, 2017 at 11:56:41 AM UTC-7, sarvi wrote: >>> >>> I do have and use eager = True for local developer testing, environment. >>> And I have been able to write test cases and they work in eager mode, >>> fine. >>> >>> >>> However, I do have a CI test environment, where I would like to be able >>> to run these same test suites with real asynchronous worker processes. >>> To make sure there are no problems when running them in a real world >>> distributed model a Implements well. >>> >>> So What I am trying to do is to create my own custom Django Test Runner >>> that >>> 1. Lets the regular django test runner create/setup the test database >>> 2. Start the Celery worker and have it talk to the same test database. >>> >>> I am having a very tough time finding a way to do this. >>> >>> The closest answer I found was >>> >>> https://stackoverflow.com/questions/42058295/make-celery-use-djangos-test-database-without-task-always-eager >>> >>> But couldn't figure out how to implement/do the Advanced: Step 3 that is >>> suggested there. >>> >>> >>> >>> On Thursday, June 22, 2017 at 11:44:23 AM UTC-7, Avraham Serour wrote: >>>> >>>> Any special reason you are not using eager=true for celery under test? >>>> >>>> On Jun 22, 2017 7:17 PM, "sarvi" <[email protected]> wrote: >>>> >>>>> >>>>> Can someone help me with how can I get my celery worker >>>>> process(standalone app outside of djanog) to talk to a django test >>>>> database >>>>> ? >>>>> >>>>> I am trying to test a celery/django app. >>>>> I plan on starting the celery worker process with a custom TestRunner. >>>>> So that the worker process starts after the django test runner has >>>>> created the test database. >>>>> >>>>> DATABASES = { >>>>> >>>>> 'default': { >>>>> >>>>> 'ENGINE': 'django.db.backends.oracle', >>>>> >>>>> .............. >>>>> >>>>> 'TEST': { >>>>> >>>>> 'USER': WIT_TEST_DB_USER, >>>>> >>>>> 'PASSWORD': WIT_TEST_DB_USER, >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> How can I setup the celery app environment so that when the tasks >>>>> access the the app.models.X, they are talk to the "test" database. >>>>> >>>>> Thanks, >>>>> Sarvi >>>>> >>>>> -- >>>>> 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 [email protected]. >>>>> To post to this group, send email to [email protected]. >>>>> Visit this group at https://groups.google.com/group/django-users. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/django-users/e9ba0c8c-a4e3-4588-99ec-46be91c4ba1b%40googlegroups.com >>>>> >>>>> <https://groups.google.com/d/msgid/django-users/e9ba0c8c-a4e3-4588-99ec-46be91c4ba1b%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> -- >> 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 [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/2bc42c7b-b601-4683-9eb4-ede77208ec5d%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/2bc42c7b-b601-4683-9eb4-ede77208ec5d%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cb2468ae-1be1-4880-a335-76c48974e36e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

