'Check set operations on recordsets.'

@mute_logger('odoo.models')
def test_80_set_operations(self):

    pa = self.env['res.partner'].search([('name', 'ilike', 'a')])
    pb = self.env['res.partner'].search([('name', 'ilike', 'b')])
    self.assertTrue(pa)
    self.assertTrue(pb)
    self.assertTrue((set(pa) & set(pb)))
    concat = (pa + pb)
    self.assertEqual(list(concat), (list(pa) + list(pb)))
    self.assertEqual(len(concat), (len(pa) + len(pb)))
    difference = (pa - pb)
    self.assertEqual(len(difference), len(set(difference)))
    self.assertEqual(set(difference), (set(pa) - set(pb)))
    self.assertLessEqual(difference, pa)
    intersection = (pa & pb)
    self.assertEqual(len(intersection), len(set(intersection)))
    self.assertEqual(set(intersection), (set(pa) & set(pb)))
    self.assertLessEqual(intersection, pa)
    self.assertLessEqual(intersection, pb)
    union = (pa | pb)
    self.assertEqual(len(union), len(set(union)))
    self.assertEqual(set(union), (set(pa) | set(pb)))
    self.assertGreaterEqual(union, pa)
    self.assertGreaterEqual(union, pb)
    ps = pa
    ms = self.env['ir.ui.menu'].search([])
    self.assertNotEqual(ps._name, ms._name)
    self.assertNotEqual(ps, ms)
    with self.assertRaises(TypeError):
        res = (ps + ms)
    with self.assertRaises(TypeError):
        res = (ps - ms)
    with self.assertRaises(TypeError):
        res = (ps & ms)
    with self.assertRaises(TypeError):
        res = (ps | ms)
    with self.assertRaises(TypeError):
        res = (ps < ms)
    with self.assertRaises(TypeError):
        res = (ps <= ms)
    with self.assertRaises(TypeError):
        res = (ps > ms)
    with self.assertRaises(TypeError):
        res = (ps >= ms)
