forked from millejoh/emacs-ipython-notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-ein-worksheet.el
40 lines (33 loc) · 1.61 KB
/
test-ein-worksheet.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(require 'ert)
(require 'ein-worksheet)
(require 'ein-testing-cell)
(defvar ein:testing-worksheet-example-data
(list (ein:testing-codecell-data "code example input")
(ein:testing-markdowncell-data "markdown example input")
(ein:testing-rawcell-data "raw example input")
(ein:testing-htmlcell-data "html example input")
(ein:testing-headingcell-data "heading example input")))
(defun ein:testing-worksheet-new ()
(make-instance 'ein:worksheet
:discard-output-p (cons #'ignore nil)))
(defun ein:testing-worksheet-to-json (cells &optional metadata)
(let* ((ws-0 (ein:worksheet-from-json (ein:testing-worksheet-new)
(list :cells cells
:metadata metadata)))
(ws-1 (ein:testing-worksheet-new))
(json-0 (ein:worksheet-to-json ws-0))
(json-1 (ein:worksheet-to-json
(ein:worksheet-from-json ws-1
(ein:json-read-from-string
(json-encode json-0))))))
(let* ((found (assoc 'metadata json-0)))
(when found
(should (cdr found))))
(should (equal json-0 json-1))))
(ert-deftest ein:worksheet-to-json/empty ()
(ein:testing-worksheet-to-json nil))
(ert-deftest ein:worksheet-to-json/example-data ()
(ein:testing-worksheet-to-json ein:testing-worksheet-example-data))
(ert-deftest ein:worksheet-to-json/example-data-with-metadata ()
(ein:testing-worksheet-to-json ein:testing-worksheet-example-data
'(:name "Worksheet name")))