Hi,

I'm running a test that fails when using Django's TestCase class, but
not when running TestCase from unittest. This is my test class:

class LoggedInUser(TestCase):
    fixtures = ['myflow']
    def setUp(self):
        self.client = Client()
        try:
            User.objects.create_user('user', 'm...@nowhere.com', 'user')
        except IntegrityError:
            pass
        self.client.login(username='user', password='user')

    def test_experiment_view(self):
        response = self.client.get('/myflow/experiment/1')
        print response.context
        self.failUnlessEqual(response.status_code, 200)

It fails with:

AssertionError: 302 != 200

when using Django's TestCase class, but everything is fine when using
unittest. Also, when it fails everything in response seems fine except
for response.context (and response.content, of course).
response.context gets lots of variables, like MEDIA_URL, LANGUAGES and
others. I have no idea where that is coming from.

This is the relevant line from urls.py:

(r'^experiment/(?P<experiment_id>\d+)$',
     'bioinformatics.myflow.views.view_experiment'),

And this is the view:

def view_experiment(request, experiment_id):
    contact = request.user.id
    # Filtering on contact and pk to ensure users can only see their
own data
    exp = get_object_or_404(Experiment.objects.filter
(exp_contact=contact),
                            pk=experiment_id)

    list = generate_list()

    files = exp.fcs_set.exclude(name__startswith='myflow_meta')
    num_files = len(files)
    files = files.order_by('btim')
    fcs_list = paginate(files,'fcs_per_page',request)
    # Create variable to include (or not) subset column in fcs file
list
    if len(subsets) > 1:
        subset_header = True
    else:
        subset_header = False
    return render_to_response('myflow/view_experiment.html',
                              {'experiment': exp,
                               'subsets': subsets,
                               'parameters': list,
                               'num_files': num_files,
                               'fcs_list': fcs_list,
                               'subset_header': subset_header
                              }
                             )

Thanks for any help. I'm not sure what I can do next to find out what
is going on.
Paulo Almeida

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to