def test_populate_inherit(self): """ Check that model with populate methods are correctly populated""" model = 'test.populate.inherit' populated = Populate.populate(self.env, 'small', [model]) records = self.check_test_populate_values( populated, model) # should be same values as base class # and additionnal_field has own values set # iterate then pseudo random self.assertEqual( records.mapped('additionnal_field')[:20], [ 'V1', 'V2', 'V3', # iterate 'V3', 'V1', 'V2', 'V1', 'V2', 'V1', 'V2', 'V2', 'V2', 'V1', 'V1', 'V3', 'V1', 'V2', 'V2', 'V3', 'V2' # pseudorandom ])
def test_populate(self): """ Check that model with populate methods are correctly populated""" model = 'test.populate' populated = Populate.populate(self.env, 'small', [model]) records = self.check_test_populate_values(populated, model) # pseudo random after cartesian with ~ 1/4 False, 3/4 True # seed is model dependant self.assertEqual(records.mapped('active')[6:20], [ True, True, True, True, True, True, False, False, True, True, True, True, False, True ]) # pseudo random after iterate self.assertEqual(records.mapped('some_ref')[5:20], [ 1, 0, 2, 4, 4, 3, 4, 1, 2, 2, 2, 4, 4, 1, 2 ])
def test_no_populate(self): """ Check that model with no populate method are not populated""" model = 'test.no.populate' populated = Populate.populate(self.env, 'small', [model]) new = populated[model] self.assertFalse(new)
def test_dependency(self): ordered_models = Populate._get_ordered_models(self.env, ['test.populate']) ordered_models_names = [model._name for model in ordered_models] self.assertEqual(ordered_models_names, ['test.populate.category', 'test.populate'])