IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Verified Commit b552073f authored by Emi Simpson's avatar Emi Simpson
Browse files

Test mapped query

parent 3216432e
......@@ -81,3 +81,23 @@ class TestQueries(unittest.TestCase):
)
bound2result = bound2.handle_results(QueryResult(0, 0, panic, panic))
self.assertEqual(bound2result, Error(result2))
def test_mapped_query(self):
build_mapped_query: Callable[[Query[str, str]], Query[str, str]] = lambda around: MappedQuery(
around,
lambda s: s[::-1],
lambda s: s.upper()
)
q1 = build_mapped_query(Noop('jan ale o toki'))
self.assertEqual(q1.get_query(), ('', ('jan ale o toki',)))
r1 = q1.handle_results(null_result)
assert isinstance(r1, Finished)
self.assertEqual(r1.value, 'ikot o ela naj')
del q1, r1
q2 = build_mapped_query(ENoop('jan ale o toki'))
self.assertEqual(q2.get_query(), ('', ('jan ale o toki',)))
r2 = q2.handle_results(null_result)
assert isinstance(r2, Error)
self.assertEqual(r2.value, 'JAN ALE O TOKI')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment