Exemple #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))
Exemple #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())
Exemple #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)
 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)
 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)
Exemple #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)
Exemple #7
0
 def test_badarg_count(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assert_method_two_args_no_keywords(h.setArgument)
Exemple #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)
Exemple #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'))
 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)
Exemple #11
0
 def test_notset(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assertIsNone(h.deleteContext('foo'))
Exemple #12
0
 def test_badarg_count(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assert_method_one_arg_no_keywords(h.deleteContext)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #18
0
 def test_badarg_count(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assert_method_no_arguments(h.getStatus)
Exemple #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)
Exemple #20
0
 def test_ok(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assertEqual(kea.NEXT_STEP_CONTINUE, h.getStatus())
 def test_badarg_count(self):
     h = kea.LibraryHandle(kea.CalloutManager())
     self.assert_method_two_args_no_keywords(h.registerCommandCallout)
Exemple #22
0
 def test_badarg_count(self):
     h = kea.CalloutHandle(kea.CalloutManager())
     self.assert_method_one_arg_no_keywords(h.setStatus)
Exemple #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)
Exemple #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())
Exemple #25
0
 def test_ok(self):
     m = kea.CalloutManager()
     self.assertEqual(1, m.use_count)
Exemple #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'))