forked from jermnelson/schema-org-editor
/
tests.py
66 lines (47 loc) · 1.82 KB
/
tests.py
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
#-------------------------------------------------------------------------------
# Name: tests
# Purpose: Schema.org Editor Unit tests
#
# Author: Jeremy Nelson
#
# Created: 2014/07/14
# Copyright: (c) Jeremy Nelson, Colorado College 2014
# Licence: MIT
#-------------------------------------------------------------------------------
import editor
import unittest
import urllib.request
class TestEditor(unittest.TestCase):
def setUp(self):
self.app = editor.editor.test_client()
def test_index(self):
rv = self.app.get("/")
assert ''
def tearDown(self):
fedora_test_uri = "/".join([editor.fedora_base, 'Test'])
delete_request = urllib.request.Request(
fedora_test_uri,
method='DELETE')
fedora_response = urllib.request.urlopen(delete_request)
class TestEntityFunctions(unittest.TestCase):
def setUp(self):
self.test_entity_uri = "/".join([editor.fedora_base, 'Test', 'Work1'])
def test_create_entity(self):
self.assertEqual(
self.test_entity_uri,
editor.create_entity(self.test_entity_uri))
def test_entity_exists(self):
editor.create_entity(self.test_entity_uri)
self.assertTrue(editor.entity_exists(self.test_entity_uri))
nonexisting_uri = "/".join([editor.fedora_base, 'Test', 'Work2'])
self.assertFalse(editor.entity_exists(nonexisting_uri))
def test_update_entity_property(self):
editor.create_entity(self.test_entity_uri)
def tearDown(self):
fedora_test_uri = "/".join([editor.fedora_base, 'Test'])
delete_request = urllib.request.Request(
fedora_test_uri,
method='DELETE')
fedora_response = urllib.request.urlopen(delete_request)
if __name__ == '__main__':
unittest.main()