test-ein-connect.el 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. (require 'ein-connect)
  2. (require 'ein-testing-notebook)
  3. (defmacro eintest:with-connected-buffer (&rest body)
  4. (declare (indent 0))
  5. `(let* ((notebook-buffer (ein:testing-notebook-make-empty))
  6. (notebook (buffer-local-value 'ein:notebook notebook-buffer)))
  7. (with-temp-buffer
  8. (erase-buffer)
  9. (ein:connect-buffer-to-notebook notebook)
  10. ,@body)))
  11. (ert-deftest ein:get-url-or-port--connect ()
  12. (eintest:with-connected-buffer
  13. (should (equal (ein:get-url-or-port)
  14. (ein:$notebook-url-or-port notebook)))))
  15. (ert-deftest ein:get-notebook--connect ()
  16. (eintest:with-connected-buffer
  17. (should (eq (ein:get-notebook) notebook))))
  18. (ert-deftest ein:get-kernel--connect ()
  19. (eintest:with-connected-buffer
  20. (should (eq (ein:get-kernel)
  21. (ein:$notebook-kernel notebook)))))
  22. (ert-deftest ein:get-cell-at-point--connect ()
  23. "`ein:get-cell-at-point' is in empty context in connected buffer."
  24. (eintest:with-connected-buffer
  25. (should-not (ein:get-cell-at-point))))
  26. (ert-deftest ein:get-traceback-data--connect ()
  27. (eintest:with-connected-buffer
  28. ;; FIXME: write test with non-empty TB
  29. (should-not (ein:get-traceback-data))))
  30. (ert-deftest ein:connect-mode-revert-buffer-resistance ()
  31. (let ((temp-file (make-temp-file "ein")))
  32. (unwind-protect
  33. (with-temp-buffer
  34. (setq buffer-file-name temp-file)
  35. (ein:connect-mode 1)
  36. (setq ein:%connect% 'very-important-value)
  37. (revert-buffer t t nil)
  38. (should ein:connect-mode)
  39. (should (eq ein:%connect% 'very-important-value)))
  40. (delete-file temp-file))))