def setup_maintainers(self):
'create some Maintainer objects'
- self.maintainer = Maintainer(name = 'Mr. Maintainer')
- self.uploader = Maintainer(name = 'Mrs. Uploader')
- self.lazyguy = Maintainer(name = 'Lazy Guy')
- self.session.add_all([self.maintainer, self.uploader, self.lazyguy])
+ self.maintainer = {}
+ self.maintainer['maintainer'] = Maintainer(name = 'Mr. Maintainer')
+ self.maintainer['uploader'] = Maintainer(name = 'Mrs. Uploader')
+ self.maintainer['lazyguy'] = Maintainer(name = 'Lazy Guy')
+ self.session.add_all(self.maintainer.values())
+ self.session.flush()
def setup_sources(self):
'create a DBSource object; but it cannot be stored in the DB yet'
- self.source = DBSource(maintainer = self.maintainer,
- changedby = self.uploader)
+ self.source = DBSource(maintainer = self.maintainer['maintainer'],
+ changedby = self.maintainer['uploader'])
def test_maintainers(self):
'''
'''
self.setup_maintainers()
- self.assertEqual('Mr. Maintainer',
- self.session.query(Maintainer)[0].name)
- self.assertEqual('Mrs. Uploader',
- self.session.query(Maintainer)[1].name)
- self.assertEqual('Lazy Guy',
- self.session.query(Maintainer)[2].name)
+ maintainer = self.maintainer['maintainer']
+ self.assertEqual(maintainer,
+ self.session.query(Maintainer).get(maintainer.maintainer_id))
+ uploader = self.maintainer['uploader']
+ self.assertEqual(uploader,
+ self.session.query(Maintainer).get(uploader.maintainer_id))
+ lazyguy = self.maintainer['lazyguy']
+ self.assertEqual(lazyguy,
+ self.session.query(Maintainer).get(lazyguy.maintainer_id))
self.setup_sources()
#TODO: needs File and Location
- #self.assertEqual(self.maintainer.maintains_sources, [self.source])
- #self.assertEqual(self.maintainer.changed_sources, [])
- #self.assertEqual(self.uploader.maintains_sources, [])
- #self.assertEqual(self.uploader.changed_sources, [self.source])
- #self.assertEqual(self.lazyguy.maintains_sources, [])
- #self.assertEqual(self.lazyguy.changed_sources, [])
+ #self.assertEqual(maintainer.maintains_sources, [self.source])
+ #self.assertEqual(maintainer.changed_sources, [])
+ #self.assertEqual(uploader.maintains_sources, [])
+ #self.assertEqual(uploader.changed_sources, [self.source])
+ #self.assertEqual(lazyguy.maintains_sources, [])
+ #self.assertEqual(lazyguy.changed_sources, [])
if __name__ == '__main__':