'Create a simple view, fill in translations, and copy it.'

def test_copy(self):

    env_en = self.env(context={})
    env_fr = self.env(context={'lang': 'fr_FR'})
    archf = '<form    string="%s"><div>%s</div><div>%s</div></form>'
    terms_en = ('Knife', 'Fork', 'Spoon')
    terms_fr = ('Couteau', 'Fourchette', 'Cuiller')
    view0 = self.env['ir.ui.view'].create({'name': 'test', 'model': 'res.partner', 'arch': (archf % terms_en)})
    for (src, value) in zip(terms_en, terms_fr):
        self.env['ir.translation'].create({'type': 'model', 'name': 'ir.ui.view,arch_db', 'lang': 'fr_FR', 'res_id': view0.id, 'src': src, 'value': value})
    self.assertEqual(view0.with_env(env_en).arch_db, (archf % terms_en))
    self.assertEqual(view0.with_env(env_fr).arch_db, (archf % terms_fr))
    view1 = view0.with_env(env_en).copy({})
    self.assertEqual(view1.with_env(env_en).arch_db, (archf % terms_en))
    self.assertEqual(view1.with_env(env_fr).arch_db, (archf % terms_fr))
    view2 = view0.with_env(env_fr).copy({})
    self.assertEqual(view2.with_env(env_en).arch_db, (archf % terms_en))
    self.assertEqual(view2.with_env(env_fr).arch_db, (archf % terms_fr))
    self.patch(type(self.env['ir.ui.view']).arch_db, 'translate', html_translate)
    view3 = view0.with_env(env_fr).copy({})
    self.assertEqual(view3.with_env(env_en).arch_db, (archf % terms_en))
    self.assertEqual(view3.with_env(env_fr).arch_db, (archf % terms_fr))
