-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move transform lookup routine along with actual functions.
Add unit test.
- Loading branch information
Showing
4 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import unittest | ||
from sippy.B2BTransforms import getTransProc | ||
|
||
class FakeCC(): | ||
acctA = None | ||
acctO = None | ||
class FakeRequest(): | ||
test: unittest.TestCase | ||
def __init__(self, test): self.test = test | ||
def getHFs(self, name): | ||
got = name | ||
want = 'X-foo-hdr' | ||
self.test.assertEqual(want, got) | ||
return tuple() | ||
class FakeEvent(): pass | ||
|
||
class TestB2BTransforms(unittest.TestCase): | ||
|
||
def test_getTransProc(self): | ||
transformations = [ | ||
('HDR2Xattrs[X-foo-hdr]', (FakeCC(), FakeRequest(self))), | ||
('Nop[]', (None, None)), | ||
] | ||
|
||
for t, args in transformations: | ||
with self.subTest(t=t, args=args): | ||
p = getTransProc(t) | ||
self.assertIsNotNone(p, f"getTransProc({t}) returned None") | ||
self.assertIsNone(p(*args), f"__call__({args}) returned not None") | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |