-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtests.py
More file actions
69 lines (58 loc) · 2.63 KB
/
tests.py
File metadata and controls
69 lines (58 loc) · 2.63 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
import json
import os
import unittest
import logging
from ome_parser import OMEtoRDF
__location__ = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(__file__)))
print(__location__)
from settings import Settings
settings=Settings()
dummy_api_url=os.environ.get('APP_HOST', "https://metadata.omero.matolab.org/api/")
dumy_url="https://omero.matolab.org/api/v0/m/images/"
dumy_image_url=dumy_url+"2"
dumy_rois_url=dumy_url+"2/rois/"
logging.basicConfig(level=logging.DEBUG)
class TestMain(unittest.TestCase):
def test_image2(self):
input_file='image2.json'
output_file=input_file.split('.')[0]+".ttl"
with open(os.path.join(__location__, 'tests', input_file)) as f:
data = json.load(f)
converter=OMEtoRDF(data,dumy_image_url)
converter.annotate_prov(dummy_api_url+'image',settings)
result=converter.to_rdf()
result.serialize(format='turtle', destination='tests/'+output_file,auto_compact=True,indent=4)
self.assertTrue(os.path.exists('tests/'+output_file))
def test_image83(self):
input_file='image83.json'
output_file=input_file.split('.')[0]+".ttl"
with open(os.path.join(__location__, 'tests', input_file)) as f:
data = json.load(f)
converter=OMEtoRDF(data,dumy_image_url)
converter.annotate_prov(dummy_api_url+'image',settings)
result=converter.to_rdf()
result.serialize(format='turtle', destination='tests/'+output_file,auto_compact=True,indent=4)
self.assertTrue(os.path.exists('tests/'+output_file))
def test_rois2(self):
input_file='rois2.json'
output_file=input_file.split('.')[0]+".ttl"
with open(os.path.join(__location__, 'tests', input_file)) as f:
data = json.load(f)
converter=OMEtoRDF(data,dumy_rois_url)
converter.annotate_prov(dummy_api_url+'rois',settings)
result=converter.to_rdf()
result.serialize(format='turtle', destination='tests/'+output_file,auto_compact=True,indent=4)
self.assertTrue(os.path.exists('tests/'+output_file))
def test_rois83(self):
input_file='rois83.json'
output_file=input_file.split('.')[0]+".ttl"
with open(os.path.join(__location__, 'tests', input_file)) as f:
data = json.load(f)
converter=OMEtoRDF(data,dumy_rois_url)
converter.annotate_prov(dummy_api_url+'rois',settings)
result=converter.to_rdf()
result.serialize(format='turtle', destination='tests/'+output_file,auto_compact=True,indent=4)
self.assertTrue(os.path.exists('tests/'+output_file))
if __name__ == '__main__':
unittest.main()