# -*- coding: utf-8 -*-
from odoo.tests.common import TransactionCase


class TestHgIndexCode(TransactionCase):

    def setUp(self):
        super().setUp()
        self.code = self.env['hg.index.code'].create({'name': 'Тестовый код'})

    def test_create(self):
        self.assertEqual(self.code.name, 'Тестовый код')

    def test_index_ids_empty_on_create(self):
        self.assertFalse(self.code.index_ids)

    def test_index_linked_to_code(self):
        index = self.env['hg.index'].create({
            'name': 'Тестовый показатель',
            'internal_code_id': self.code.id,
        })
        self.assertIn(index, self.code.index_ids)
