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.

42 lines
1.3 KiB

  1. # Copyright 2020 Coop IT Easy SCRL fs
  2. # Robin Keunen <robin@coopiteasy.be>
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. import json
  5. import requests
  6. from odoo.addons.base_rest.controllers.main import _PseudoCollection
  7. from odoo.addons.component.core import WorkContext
  8. from .common import HOST, PORT, BaseEMCRestCase
  9. class TestPing(BaseEMCRestCase):
  10. def test_public_service(self):
  11. collection = _PseudoCollection("emc.services", self.env)
  12. emc_services_env = WorkContext(
  13. model_name="rest.service.registration", collection=collection
  14. )
  15. service = emc_services_env.component(usage="ping")
  16. result = service.test()
  17. self.assertTrue("message" in result)
  18. def test_ping_route(self):
  19. # public route
  20. path = "/api/ping/test"
  21. url = "http://{}:{}{}".format(HOST, PORT, path)
  22. response = requests.get(url)
  23. self.assertEquals(response.status_code, 200)
  24. content = json.loads(response.content.decode("utf-8"))
  25. self.assertTrue("message" in content)
  26. def test_search_route(self):
  27. response = self.http_get("/api/ping")
  28. self.assertEquals(response.status_code, 200)
  29. content = json.loads(response.content.decode("utf-8"))
  30. self.assertTrue("message" in content)