fix: add docs, tests; tweak some handler method signatures
This commit is contained in:
parent
e4a4e85cf6
commit
d11e186df9
16 changed files with 345 additions and 15 deletions
66
tests/test_handler.py
Normal file
66
tests/test_handler.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
# -*- 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')
|
Loading…
Add table
Add a link
Reference in a new issue