Ejemplo n.º 1
0
 def test_ok(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     foo = utils.Logger()
     h.setContext('foo', foo)
     self.assertEqual(3, sys.getrefcount(foo))
     self.assertIsNone(h.deleteContext('foo'))
     self.assertEqual(2, sys.getrefcount(foo))
Ejemplo n.º 2
0
 def test_response4_ok(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     x = kea.Pkt4(kea.DHCPACK, 42)
     self.assertEqual(1, x.use_count)
     self.assertIsNone(h.setArgument('response4', x))
     self.assertEqual(2, x.use_count)
     self.assertEqual(kea.DHCPACK, h.getArgument('response4').getType())
Ejemplo n.º 3
0
 def test_notset(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     with self.assertRaises(TypeError) as cm:
         h.getContext('foo')
     self.assertEqual(
         ("unable to find callout context associated with the current"
          " library index (-1)", ), cm.exception.args)
Ejemplo n.º 4
0
 def test_ok(self):
     def foo():
         pass
     h = kea.LibraryHandle(kea.CalloutManager())
     with self.assertRaises(RuntimeError) as cm:
         h.registerCommandCallout('foo', foo)
     self.assertEqual(("only supported in embedded mode",), cm.exception.args)
Ejemplo n.º 5
0
 def test_nadarg_type(self):
     h = kea.LibraryHandle(kea.CalloutManager())
     with self.assertRaises(TypeError) as cm:
         h.registerCommandCallout(1, 42)
     self.assertEqual(("argument 1 must be str, not int",), cm.exception.args)
     with self.assertRaises(TypeError) as cm:
         h.registerCommandCallout('foo', 42)
     self.assertEqual(("callout must be callable",), cm.exception.args)
Ejemplo n.º 6
0
 def test_lease4_ok(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     x = kea.Lease4()
     x.addr = '1.2.3.4'
     self.assertEqual(1, x.use_count)
     self.assertIsNone(h.setArgument('lease4', x))
     self.assertEqual(2, x.use_count)
     self.assertEqual('1.2.3.4', h.getArgument('lease4').addr)
Ejemplo n.º 7
0
 def test_badarg_count(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assert_method_two_args_no_keywords(h.setArgument)
Ejemplo n.º 8
0
 def test_ok(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     with self.assertRaises(TypeError) as cm:
         h.getArgument('query4')
     self.assertEqual(("unable to find argument with name query4", ),
                      cm.exception.args)
Ejemplo n.º 9
0
 def test_response_ok(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assertIsNone(h.setArgument('response', [1, 'two', None]))
     self.assertEqual([1, 'two', None], h.getArgument('response'))
Ejemplo n.º 10
0
 def test_ok(self):
     m = kea.CalloutManager()
     h = kea.LibraryHandle(m)
     # LibraryHandle has pointer to CalloutManager, not shared_ptr
     self.assertEqual(1, m.use_count)
     self.assertIsInstance(h, kea.LibraryHandle)
Ejemplo n.º 11
0
 def test_notset(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assertIsNone(h.deleteContext('foo'))
Ejemplo n.º 12
0
 def test_badarg_count(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assert_method_one_arg_no_keywords(h.deleteContext)
Ejemplo n.º 13
0
 def test_ok(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     foo = utils.Logger()
     h.setContext('foo', foo)
     bar = h.getContext('foo')
     self.assertIs(foo, bar)
Ejemplo n.º 14
0
 def test_ok(self):
     m = kea.CalloutManager()
     h = kea.CalloutHandle(m)
     self.assertEqual(2, m.use_count)
     del h
     self.assertEqual(1, m.use_count)
Ejemplo n.º 15
0
 def test_response_bad_type(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     with self.assertRaises(TypeError) as cm:
         h.setArgument('response', self)
     self.assertEqual(("unhandled type TestCalloutHandle_setArgument", ),
                      cm.exception.args)
Ejemplo n.º 16
0
 def test_badarg_type(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     with self.assertRaises(TypeError) as cm:
         h.setArgument(3, 4)
     self.assertEqual(("argument 1 must be str, not int", ),
                      cm.exception.args)
Ejemplo n.º 17
0
 def test_badarg_value(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     with self.assertRaises(ValueError) as cm:
         h.setArgument('foo', 3)
     self.assertEqual(("unknown argument", ), cm.exception.args)
Ejemplo n.º 18
0
 def test_badarg_count(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assert_method_no_arguments(h.getStatus)
Ejemplo n.º 19
0
 def test_query4_bad_type(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     with self.assertRaises(TypeError) as cm:
         h.setArgument('query4', 3)
     self.assertEqual(("expected Pkt4 object", ), cm.exception.args)
Ejemplo n.º 20
0
 def test_ok(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assertEqual(kea.NEXT_STEP_CONTINUE, h.getStatus())
Ejemplo n.º 21
0
 def test_badarg_count(self):
     h = kea.LibraryHandle(kea.CalloutManager())
     self.assert_method_two_args_no_keywords(h.registerCommandCallout)
Ejemplo n.º 22
0
 def test_badarg_count(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assert_method_one_arg_no_keywords(h.setStatus)
Ejemplo n.º 23
0
 def test_badarg_type(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     with self.assertRaises(TypeError) as cm:
         h.setStatus('foo')
     self.assertEqual(("an integer is required (got type str)", ),
                      cm.exception.args)
Ejemplo n.º 24
0
 def test_ok(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assertIsNone(h.setStatus(kea.NEXT_STEP_SKIP))
     self.assertEqual(kea.NEXT_STEP_SKIP, h.getStatus())
Ejemplo n.º 25
0
 def test_ok(self):
     m = kea.CalloutManager()
     self.assertEqual(1, m.use_count)
Ejemplo n.º 26
0
 def test_command_ok(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assertIsNone(h.setArgument('command', {'foo': 42}))
     self.assertEqual({'foo': 42}, h.getArgument('command'))