I'm using fixture to test a Pylons app, but I stumbled upon a problem.
Let's say I have such data set:
class CompanyData(DataSet):
class test_company:
company_full_name = u'Firma Tęst'
company_short_name = u'TęstCo'
class UserData(DataSet):
class test_user:
user_login = 'testuser'
user_password = 'test'
company = CompanyData.test_company
Now, the problem is, that when I use this data in a functional test (like described at http://farmdev.com/projects/fixture/using-fixture-with-pylons.html), I can't obtain the id (primary key) of the company.
In my application the user after logging in should be redirected to the company profile page and that's why I need the company's id. The test looks more or less like this:
self.app.post(url(controller='main', action='login'), params={
'login': UserData.test_user.user_login,
'password': UserData.test_user.user_password
})
response = self.app.get(url(
controller='events', action='index',
company_id=UserData.test_user.company.company_id, # This doesn't work
view='active'))
assert ... in response
The first request logs in the user and the second one checks if after logging in she can access the company profile page.
This way I get:
AttributeError: class test_company has no attribute 'company_id'
I also tried:
UserData.test_user.company.ref('company_id')
But it results in:
<Ref.RefValue for CompanyData.test_company.company_id (not yet loaded)>
which seems weird to me... Why isn't it loaded?
Is there any way of finding out what is the primary key?
company_id
is the primary key column in thecompany
table, not a foreign key in theuser
table (which isuser_company_id
). Don't blame me for the naming convention, I didn't design this database, I just work with it ;) – Slosh