-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_iiif.py
More file actions
90 lines (71 loc) · 2.94 KB
/
Copy pathtest_iiif.py
File metadata and controls
90 lines (71 loc) · 2.94 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import unittest
import spider as sp
import os
import utils
class TestWeb(unittest.TestCase):
def setUp(self):
# Delete if already exists:
utils.remove_file(os.path.join(os.getcwd(), "Test-Manifest.json"))
utils.remove_web("tempNetCon")
utils.remove_web("tempFromMedia")
utils.remove_dir(os.path.join(os.getcwd(), "testManifestNetwork"))
def tearDown(self):
# Delete if exists:
utils.remove_web("tempNetCon")
utils.remove_web("tempFromMedia")
# Comment these out if you wish to keep the manifest output:
utils.remove_file(os.path.join(os.getcwd(), "Test-Manifest.json"))
#utils.remove_dir(os.path.join(os.getcwd(), "testManifestNetwork"))
def test_iiif(self):
manifest = sp.Manifest(
writepath = os.getcwd(),
path = "www.test.com",
filename = "Test-Manifest.json",
label = {
"en" : ["Test Manifest"],
"fr" : ["Manifest Test"]
}
)
canvas1 = manifest.addCanvas(
width = 100,
height = 100,
duration = 10
)
annotPage1 = canvas1.addAnnotationPage(
type = "page"
)
mediaItem1 = annotPage1.addMediaItem()
manifest.write()
self.assertTrue(os.path.isfile(os.path.join(os.getcwd(), "Test-Manifest.json")))
manifestFileRead = utils.readJson(os.path.join(os.getcwd(), "Test-Manifest.json"))
self.assertIsNotNone(manifestFileRead)
def test_network_to_manifest(self):
# 1. Create a web with some content:
web = utils.create_basic_web("tempNetCon", "test network", 10)
# Create the network
network = sp.webToNetworkx(web)
# Network to manifest:
manifest = sp.networkxToManifest(network, web, path = "http://localhost:9000/data/", writePath = os.getcwd(), networkName = "test network")
self.assertTrue(os.path.isfile(os.path.join(os.getcwd(), "test_network.json")))
self.assertTrue(os.path.isfile(os.path.join(os.getcwd(), "media/test_network.png")))
manifestFileRead = utils.readJson(os.path.join(os.getcwd(), "test_network.json"))
self.assertIsNotNone(manifestFileRead)
# TODO : Do some checking on the manifest object here...
# Clean up
utils.remove_file(os.path.join(os.getcwd(), "test_network.json"))
utils.remove_dir(os.path.join(os.getcwd(), "media"))
def test_web_to_iiif(self):
web = utils.create_web_from_media(
"/Users/jacob/Documents/Git Repos/spider-python/Examples/Example-Media",
"tempFromMedia"
)
sp.webToMemoRekall(
web,
writePath = os.path.join(os.getcwd(), "testManifestNetwork"),
path = "http://localhost:9000/data/",
removePrevious = [True, True],
copyMedia = True
)
# Run
if __name__ == "__main__":
unittest.main()