emacs-ipython-notebook/tests/test-ein-connect.el
Takafumi Arakaki 96d2babff1 Move test utils to ein-testing-notebook.el
So that I can avoid loading test-ein-notebook or
test-ein-cell-notebook for using these utilities.
2012-08-24 19:29:37 +02:00

35 lines
1.2 KiB
EmacsLisp

(require 'ein-connect)
(require 'ein-testing-notebook)
(defmacro eintest:with-connected-buffer (&rest body)
(declare (indent 0))
`(let* ((notebook-buffer (ein:testing-notebook-make-empty))
(notebook (buffer-local-value 'ein:notebook notebook-buffer)))
(with-temp-buffer
(erase-buffer)
(ein:connect-buffer-to-notebook notebook)
,@body)))
(ert-deftest ein:get-url-or-port--connect ()
(eintest:with-connected-buffer
(should (equal (ein:get-url-or-port)
(ein:$notebook-url-or-port notebook)))))
(ert-deftest ein:get-notebook--connect ()
(eintest:with-connected-buffer
(should (eq (ein:get-notebook) notebook))))
(ert-deftest ein:get-kernel--connect ()
(eintest:with-connected-buffer
(should (equal (ein:get-kernel)
(ein:$notebook-kernel notebook)))))
(ert-deftest ein:get-cell-at-point--connect ()
"`ein:get-cell-at-point' is in empty context in connected buffer."
(eintest:with-connected-buffer
(should-not (ein:get-cell-at-point))))
(ert-deftest ein:get-traceback-data--connect ()
(eintest:with-connected-buffer
;; FIXME: write test with non-empty TB
(should-not (ein:get-traceback-data))))