You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 LasLabs Inc.
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
  4. from odoo.exceptions import UserError, ValidationError
  5. from .common import Common
  6. class TestExternalSystem(Common):
  7. def setUp(self):
  8. super(TestExternalSystem, self).setUp()
  9. self.record = self.env.ref('base_external_system.external_system_os')
  10. def test_get_system_types(self):
  11. """It should return at least the test record's interface."""
  12. self.assertIn(
  13. (self.record._name, self.record._description),
  14. self.env['external.system']._get_system_types(),
  15. )
  16. def test_check_fingerprint_blank(self):
  17. """It should not allow blank fingerprints when checking enabled."""
  18. with self.assertRaises(ValidationError):
  19. self.record.write({
  20. 'ignore_fingerprint': False,
  21. 'fingerprint': False,
  22. })
  23. def test_check_fingerprint_allowed(self):
  24. """It should not raise a validation error if there is a fingerprint."""
  25. self.record.write({
  26. 'ignore_fingerprint': False,
  27. 'fingerprint': 'Data',
  28. })
  29. self.assertTrue(True)
  30. def test_client(self):
  31. """It should yield the open interface client."""
  32. with self._mock_method('client', self.record) as magic:
  33. with self.record.system_id.client() as client:
  34. self.assertEqual(client, magic().__enter__())
  35. def test_create_creates_and_assigns_interface(self):
  36. """It should create and assign the interface on record create."""
  37. self.assertEqual(
  38. self.record.interface._name, 'external.system.os',
  39. )
  40. def test_action_test_connection(self):
  41. """It should proxy to the interface connection tester."""
  42. with self.assertRaises(UserError):
  43. self.record.system_id.action_test_connection()