The User object and all other non-string data should be passed in a different environ key, not AUTH_USER, and the test should look for it there. Repoze.who/what works this way, but I don't know offhand the name of the key. It's in the Repoze docs.
On Fri, Aug 13, 2010 at 2:16 AM, waugust <[email protected]> wrote: > Well I have spent allot of time trying to figure out my next problem > here before I further expose the depths of my ignorance here... > > I tried passing in AUTH_USER as a string user name and it naturally > works for authentication; as did passing in > repoze.what.credentials:<my user object>. > > The problem I have is that my User model has a ManyToOne relationship > to a Company model. In my controller I use the environ. > [AUTH_USER].company on another object (say, > template.owner=user.company). > > Passing AUTH_USER as a string naturally gives me "string has no > attribute 'company;". When I pass the User object in for > repoze.what.credentials I get 'NoneType' object has no attribute > 'company'. > > My TestModel class in base has the company attribute of the user set > in setUp, so I don't get it... > > My thanks in advance for you nurturing me along here. > > On Aug 12, 6:29 pm, Mike Orr <[email protected]> wrote: >> On Thu, Aug 12, 2010 at 4:58 PM, Richard Harding <[email protected]> >> wrote: >> > On Thu, Aug 12, 2010 at 3:49 PM, waugust <[email protected]> wrote: >> >> This is most likely a very trivial question, but believe me I did my >> >> due diligence and googled but alas I can't find the answer. >> >> >> All I'm trying to do is write tests for my controllers but I fail to >> >> see how to set an AUTH_USER environ variable. >> >> >> I thought to just instantiate my User model and pass it in the headers >> >> attribute of self.app.post though i get "AssertionError: Environmental >> >> variable HTTP_AUTH_USER is not a string:" >> >> >> What am I missing here? How do I mimic a logged in user when testing >> >> my controllers? >> >> The others have explained the Repoze configuration better than I can, >> but I'll just point out that AUTH_USER has to be a string because it >> was defined in the early 1990s before the rise of OO scripting >> languages, so if you want interoperability with other software, it has >> to be a string. >> >> -- >> Mike Orr <[email protected]> > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en. > > -- Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
