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


class TestHgNode(TransactionCase):

    def setUp(self):
        super().setUp()
        self.node = self.env['hg.node'].create({
            'name': 'Тестовая вершина',
            'res_model': 'hg.node',
            'res_id': 1,
        })

    def test_create(self):
        self.assertEqual(self.node.name, 'Тестовая вершина')
        self.assertEqual(self.node.res_model, 'hg.node')

    def test_goto_related_returns_action(self):
        action = self.node.goto_related()
        self.assertEqual(action['type'], 'ir.actions.act_window')
        self.assertEqual(action['res_model'], self.node.res_model)
        self.assertEqual(action['res_id'], self.node.res_id)
        self.assertEqual(action['view_mode'], 'form')
