Example #1
0
    def test_purge_kernels_with_failures(self):  # depends on start_kernel
        for i in xrange(5):
            self.a.start_kernel()
        self.a._kernels.add(55)
        self.a._kernels.add(66)

        retval = self.a.purge_kernels()
        assert_in(55, retval)
        assert_in(66, retval)
        assert_len(retval, 2)
    def test_purge_kernels_with_failures(self):  # depends on start_kernel
        for i in xrange(5):
            self.a.start_kernel()
        self.a._kernels.add(55)
        self.a._kernels.add(66)

        retval = self.a.purge_kernels()
        assert_in(55, retval)
        assert_in(66, retval)
        assert_len(retval, 2)
 def test_get_kernel_ids_success(self):
     self._populate_comps_kernels()
     x = self.a.get_kernel_ids("testcomp1")
     y = self.a.get_kernel_ids("testcomp2")
     assert_len(x, 2)
     assert_len(y, 1)
     assert_in("kone", x)
     assert_in("ktwo", x)
     assert_not_in("kthree", x)
     assert_in("kthree", y)
Example #4
0
 def test_get_kernel_ids_success(self):
     self._populate_comps_kernels()
     x = self.a.get_kernel_ids("testcomp1")
     y = self.a.get_kernel_ids("testcomp2")
     assert_len(x, 2)
     assert_len(y, 1)
     assert_in("kone", x)
     assert_in("ktwo", x)
     assert_not_in("kthree", x)
     assert_in("kthree", y)
Example #5
0
    def test_restart_kernel_success(self): # depends on add_computer, new_session
        x = self.a.add_computer(self.default_comp_config)
        kern1 = self.a.new_session()
        kern2 = self.a.new_session()

        with capture_output() as (out, err):
            self.a.restart_kernel(kern2)
        out = out[0]

        y = ast.literal_eval(out)
        assert_is_instance(y, dict)
        assert_in("content", y)
        assert_len(y["content"], 2)
        assert_in("type", y)
        assert_equal(y["type"], "success")
        assert_in("kernel_id", y["content"])
        assert_uuid(y["content"]["kernel_id"])
        assert_in("connection", y["content"])
        assert_len(y["content"]["connection"], 6)
        for s in ("stdin_port", "hb_port", "shell_port", "iopub_port"):
            assert_in(s, y["content"]["connection"])
            assert_len(str(y["content"]["connection"][s]), 5)        
        assert_in("ip", y["content"]["connection"])
        assert_equal(y["content"]["connection"]["ip"], "127.0.0.1")
        assert_in("key", y["content"]["connection"])
        assert_uuid(y["content"]["connection"]["key"])
    def test_restart_kernel_success(self):  # depends on add_computer, new_session
        x = self.a.add_computer(self.default_comp_config)
        kern1 = self.a.new_session()
        kern2 = self.a.new_session()

        with capture_output() as (out, err):
            self.a.restart_kernel(kern2)
        out = out[0]

        y = ast.literal_eval(out)
        assert_is_instance(y, dict)
        assert_in("content", y)
        assert_len(y["content"], 2)
        assert_in("type", y)
        assert_equal(y["type"], "success")
        assert_in("kernel_id", y["content"])
        assert_uuid(y["content"]["kernel_id"])
        assert_in("connection", y["content"])
        assert_len(y["content"]["connection"], 6)
        for s in ("stdin_port", "hb_port", "shell_port", "iopub_port"):
            assert_in(s, y["content"]["connection"])
            assert_len(str(y["content"]["connection"][s]), 5)
        assert_in("ip", y["content"]["connection"])
        assert_equal(y["content"]["connection"]["ip"], "127.0.0.1")
        assert_in("key", y["content"]["connection"])
        assert_uuid(y["content"]["connection"]["key"])
 def test_start_kernel_success(self):
     y = self.a.start_kernel()
     assert_is_instance(y, dict)
     assert_len(y, 2)
     assert_in("kernel_id", y)
     assert_uuid(y["kernel_id"])
     assert_in(y["kernel_id"], self.a._kernels)
     assert_in("connection", y)
     assert_len(y["connection"], 6)
     for s in ("stdin_port", "hb_port", "shell_port", "iopub_port"):
         assert_in(s, y["connection"])
         assert_len(str(y["connection"][s]), 5)
     assert_in("ip", y["connection"])
     assert_equal(y["connection"]["ip"], "127.0.0.1")
     assert_in("key", y["connection"])
     assert_uuid(y["connection"]["key"])
Example #8
0
 def test_start_kernel_success(self):
     y = self.a.start_kernel()
     assert_is_instance(y, dict)
     assert_len(y, 2)
     assert_in("kernel_id", y)
     assert_uuid(y["kernel_id"])
     assert_in(y["kernel_id"], self.a._kernels)
     assert_in("connection", y)
     assert_len(y["connection"], 6)
     for s in ("stdin_port", "hb_port", "shell_port", "iopub_port"):
         assert_in(s, y["connection"])
         assert_len(str(y["connection"][s]), 5)
     assert_in("ip", y["connection"])
     assert_equal(y["connection"]["ip"], "127.0.0.1")
     assert_in("key", y["connection"])
     assert_uuid(y["connection"]["key"])
Example #9
0
def test_init():
    fkm = forking_kernel_manager.ForkingKernelManager(
        "testing.log", '127.0.0.1', update_function=test_init)
    assert_len(fkm.kernels, 0)
    assert_equal(fkm.filename, "testing.log")
    assert_in("function test_init at ", repr(fkm.update_function))
def test_init():
    umkm = untrusted_kernel_manager.UntrustedMultiKernelManager("testing.log", "127.0.0.1", update_function=test_init)
    assert_len(umkm._kernels, 0)
    assert_equal(umkm.filename, "testing.log")
    assert_is(hasattr(umkm, "fkm"), True)
Example #11
0
 def test_get_kernel_ids_no_args(self):
     self._populate_comps_kernels()
     self.a._kernels = {"a": None, "b": None, "c": None}
     x = self.a.get_kernel_ids()
     assert_len(x, 3)
 def test_get_kernel_ids_no_args(self):
     self._populate_comps_kernels()
     self.a._kernels = {"a": None, "b": None, "c": None}
     x = self.a.get_kernel_ids()
     assert_len(x, 3)
Example #13
0
def test_init():
    tmkm = trusted_kernel_manager.TrustedMultiKernelManager()
    assert_len(tmkm._kernels.keys(), 0)
    assert_len(tmkm._comps.keys(), 0)
    assert_len(tmkm._clients.keys(), 0)
    assert_is(hasattr(tmkm, "context"), True)
Example #14
0
 def test_setup_ssh_connection_success(self):
     x = self.a._setup_ssh_connection("localhost", username=None)
     assert_in("AutoAddPolicy", str(x._policy))
     assert_len(x.get_host_keys(), 1)
def test_init():
    tmkm = trusted_kernel_manager.TrustedMultiKernelManager()
    assert_len(tmkm._kernels.keys(), 0)
    assert_len(tmkm._comps.keys(), 0)
    assert_len(tmkm._clients.keys(), 0)
    assert_is(hasattr(tmkm, "context"), True)
 def test_setup_ssh_connection_success(self):
     x = self.a._setup_ssh_connection("localhost", username=None)
     assert_in("AutoAddPolicy", str(x._policy))
     assert_len(x.get_host_keys(), 1)
Example #17
0
def test_init():
    umkm = untrusted_kernel_manager.UntrustedMultiKernelManager(
        "testing.log", '127.0.0.1', update_function=test_init)
    assert_len(umkm._kernels, 0)
    assert_equal(umkm.filename, "testing.log")
    assert_is(hasattr(umkm, "fkm"), True)
Example #18
0
 def test_get_kernel_ids_invalid_comp(self):
     self._populate_comps_kernels()
     x = self.a.get_kernel_ids("testcomp3")
     assert_len(x, 0)
def test_init():
    fkm = forking_kernel_manager.ForkingKernelManager("testing.log", '127.0.0.1', update_function=test_init)
    assert_len(fkm.kernels, 0)
    assert_equal(fkm.filename, "testing.log")
    assert_in("function test_init at ", repr(fkm.update_function))
 def test_get_kernel_ids_invalid_comp(self):
     self._populate_comps_kernels()
     x = self.a.get_kernel_ids("testcomp3")
     assert_len(x, 0)