mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-19 08:59:27 +01:00
Abstracted out an assertError method for testing specs.
This commit is contained in:
parent
2b6994428e
commit
307f50137b
@ -47,6 +47,10 @@ class CommandsTestCase(SupyTestCase):
|
|||||||
self.assertEqual(state.args, expected,
|
self.assertEqual(state.args, expected,
|
||||||
'Expected %r, got %r' % (expected, state.args))
|
'Expected %r, got %r' % (expected, state.args))
|
||||||
|
|
||||||
|
def assertError(self, spec, given):
|
||||||
|
self.assertRaises(callbacks.Error,
|
||||||
|
self.assertState, spec, given, given)
|
||||||
|
|
||||||
|
|
||||||
class GeneralContextTestCase(CommandsTestCase):
|
class GeneralContextTestCase(CommandsTestCase):
|
||||||
def testEmptySpec(self):
|
def testEmptySpec(self):
|
||||||
@ -65,8 +69,7 @@ class GeneralContextTestCase(CommandsTestCase):
|
|||||||
self.assertState([rest(None)], ['foo', 'bar', 'baz'], ['foo bar baz'])
|
self.assertState([rest(None)], ['foo', 'bar', 'baz'], ['foo bar baz'])
|
||||||
|
|
||||||
def testRestRequiresArgs(self):
|
def testRestRequiresArgs(self):
|
||||||
self.assertRaises(callbacks.ArgumentError,
|
self.assertError([rest('something')], [])
|
||||||
self.assertState, [rest('something')], [], ['asdf'])
|
|
||||||
|
|
||||||
def testOptional(self):
|
def testOptional(self):
|
||||||
spec = [optional('int', 999), None]
|
spec = [optional('int', 999), None]
|
||||||
@ -77,8 +80,7 @@ class GeneralContextTestCase(CommandsTestCase):
|
|||||||
spec = [additional('int', 999)]
|
spec = [additional('int', 999)]
|
||||||
self.assertState(spec, ['12'], [12])
|
self.assertState(spec, ['12'], [12])
|
||||||
self.assertState(spec, [], [999])
|
self.assertState(spec, [], [999])
|
||||||
self.assertRaises(callbacks.Error,
|
self.assertError(spec, ['foo'])
|
||||||
self.assertState, spec, ['foo'], ['asdf'])
|
|
||||||
|
|
||||||
def testReverse(self):
|
def testReverse(self):
|
||||||
spec = [reverse('positiveInt'), 'float', 'text']
|
spec = [reverse('positiveInt'), 'float', 'text']
|
||||||
@ -100,8 +102,8 @@ class GeneralContextTestCase(CommandsTestCase):
|
|||||||
def testMany(self):
|
def testMany(self):
|
||||||
spec = [many('int')]
|
spec = [many('int')]
|
||||||
self.assertState(spec, ['1', '2', '3'], [[1, 2, 3]])
|
self.assertState(spec, ['1', '2', '3'], [[1, 2, 3]])
|
||||||
self.assertRaises(callbacks.Error,
|
self.assertError(spec, [])
|
||||||
self.assertState, spec, [], ['asdf'])
|
|
||||||
def testChannelRespectsNetwork(self):
|
def testChannelRespectsNetwork(self):
|
||||||
spec = ['channel', 'text']
|
spec = ['channel', 'text']
|
||||||
self.assertState(spec, ['#foo', '+s'], ['#foo', '+s'])
|
self.assertState(spec, ['#foo', '+s'], ['#foo', '+s'])
|
||||||
@ -132,8 +134,7 @@ class GeneralContextTestCase(CommandsTestCase):
|
|||||||
self.assertState(spec, ['f'], ['foo'])
|
self.assertState(spec, ['f'], ['foo'])
|
||||||
self.assertState(spec, ['bar'], ['bar'])
|
self.assertState(spec, ['bar'], ['bar'])
|
||||||
self.assertState(spec, ['baz'], ['baz'])
|
self.assertState(spec, ['baz'], ['baz'])
|
||||||
self.assertRaises(callbacks.ArgumentError,
|
self.assertError(spec, ['ba'])
|
||||||
self.assertState, spec, ['ba'], ['baz'])
|
|
||||||
|
|
||||||
class ConverterTestCase(CommandsTestCase):
|
class ConverterTestCase(CommandsTestCase):
|
||||||
def testUrlAllowsHttps(self):
|
def testUrlAllowsHttps(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user