Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4249164
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:21:38+00:00 2026-05-21T04:21:38+00:00

I have the following in tests.py. def setUp(self): self.client = Client() self.client.get(‘/homepage’,{‘join’:’NPO2′,’siteid’:1450}) self.client.session.save() self.oraganisation_list

  • 0

I have the following in tests.py.

def setUp(self):
    self.client = Client()
    self.client.get('/homepage',{'join':'NPO2','siteid':1450})
    self.client.session.save()
    self.oraganisation_list = ['NPO1','NPO2','NPO3']
    self.pay_recursion_list = ['annual','monthly','bi-annual','quarter']
def test_paytermpage(self):
    for org in self.organisation_list:
        response = self.client.get('',{'join':org,'siteid':1450})
        self.failUnlessEqual(response.status_code,200)
        self.assertTemplateUsed(response,'some.html')
def test_infopage(self):
    for term in self.pay_recurstion_list:
        response = self.client.post('',{'pay-term':term,'submit':'payterm'})
        self.failUnlessEqual(response.status_code,200)

test_infopage() is failing and here is the traceback.

Traceback (most recent call last):
  File "/var/lib/django/bsdata/shoppingcart/tests.py", line 50, in test_infopage
    response = self.client.post('',{'pay-term':term,'submit':'payterm'})
  File "/usr/lib/pymodules/python2.6/django/test/client.py", line 313, in post
    response = self.request(**r)
  File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py", line 92, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/var/lib/django/.../views.py", line 22, in start
    term,costdict,webobj = costInfo(request)
  File "/var/lib/django/...views.py", line 238, in getCostInfo
    cost_dict = Site.objects.getDict(request.session['siteid']) 
  File "/var/lib/django/.../managers.py", line 16, in getLoadedDict
    siteobj = Site.objects.get(pk=agent)
  File "/usr/lib/pymodules/python2.6/django/db/models/manager.py", line 120, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 305, in get
    % self.model._meta.object_name)
DoesNotExist: Site matching query does not exist.

I did debug to see what value ‘agent’ in siteobj = Site.objects.get(pk=agent) is getting its a valid integer.

Surprisingly both of them are working when tested from shell like this

setup_test_environment()
client = Client()
client.get('/shoppingcart',{'join':'NPO1','siteid':1450})
client.session.save()
oraganisation_list = ['NPO1','NPO2','NPO3']
pay_recursion_list = ['annual','monthly','bi-annual','quarter']
for org in oraganisation_list:
    response = client.get('',{'join':org,'siteid':1450})
    TestCase.failUnlessEqual(t,response.status_code,200)
for term in pay_recursion_list:
    response = client.post('',{'pay-term':term,'submit':'payterm'})
    TestCase.failUnlessEqual(t,response.status_code,200)

Sorry for too much info,didn’t know how to explain better.
Any ideas would be highly helpful for this newbie. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:21:39+00:00Added an answer on May 21, 2026 at 4:21 am

    The Django test runner uses a different database than your production data. If your site requires a Site to exist, you should either add it in your Test setUp, or you should require a fixture that loads the site.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: def add_record(self,values): self.sql.execute(INSERT INTO TEST VALUES (?,?) % values)
I have a test: def setup @cart = FactoryGirl.create(:cart_with_1_row) end test should get show
I have the following python code. class MainPage(BaseHandler): def post(self, location_id): reservations = self.request.get_all('reservations')
I have the following code class SomeClass def initialize(opts) if opts[:should_load] load else setup(opts[:path])
I have the following setup - and don't get any response when I visit
Assume I have the following ; def test(): while 1: a = b time.sleep(60)
I have the following as my unit test: void testCreateDealer() { mockForConstraintsTests(Dealer) def _dealer=
I have the following controller: class Tests extends CI_Controller { public function update_record_test() {
I have the following code (correct for my simple tests) for a linked list
I have the following actor for which I would like to create unit tests

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.