wutta-corepos/tests/test_handler.py

67 lines
2.4 KiB
Python

# -*- coding: utf-8; -*-
from wuttjamaican.testing import ConfigTestCase
from wuttjamaican.exc import ConfigurationError
from wutta_corepos import handler as mod
class TestCoreposHandler(ConfigTestCase):
def make_handler(self):
return mod.CoreposHandler(self.config)
def test_get_office_url(self):
handler = self.make_handler()
# null by default
self.assertIsNone(handler.get_office_url())
# error if required
self.assertRaises(ConfigurationError, handler.get_office_url, require=True)
# config can specify (traliing slash is stripped)
self.config.setdefault('corepos.office.url', 'http://localhost/fannie/')
self.assertEqual(handler.get_office_url(), 'http://localhost/fannie')
self.assertEqual(handler.get_office_url(require=True), 'http://localhost/fannie')
def test_get_office_department_url(self):
handler = self.make_handler()
# null
self.assertIsNone(handler.get_office_department_url(7))
# typical
self.config.setdefault('corepos.office.url', 'http://localhost/fannie/')
self.assertEqual(handler.get_office_department_url(7), 'http://localhost/fannie/item/departments/DepartmentEditor.php?did=7')
def test_get_office_likecode_url(self):
handler = self.make_handler()
# null
self.assertIsNone(handler.get_office_likecode_url(7))
# typical
self.config.setdefault('corepos.office.url', 'http://localhost/fannie/')
self.assertEqual(handler.get_office_likecode_url(7), 'http://localhost/fannie/item/likecodes/LikeCodeEditor.php?start=7')
def test_get_office_product_url(self):
handler = self.make_handler()
# null
self.assertIsNone(handler.get_office_product_url('07430500132'))
# typical
self.config.setdefault('corepos.office.url', 'http://localhost/fannie/')
self.assertEqual(handler.get_office_product_url('07430500132'), 'http://localhost/fannie/item/ItemEditorPage.php?searchupc=07430500132')
def test_get_office_vendor_url(self):
handler = self.make_handler()
# null
self.assertIsNone(handler.get_office_vendor_url(7))
# typical
self.config.setdefault('corepos.office.url', 'http://localhost/fannie/')
self.assertEqual(handler.get_office_vendor_url(7), 'http://localhost/fannie/item/vendors/VendorIndexPage.php?vid=7')