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
         ])
Esempio n. 2
0
    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)