7
7
from ibm_watson .compare_comply_v1 import TableReturn
8
8
9
9
10
- @pytest .mark .skipif (
11
- os . getenv ( 'VCAP_SERVICES' ) is None , reason = 'requires VCAP_SERVICES' )
10
+ @pytest .mark .skipif (os . getenv ( 'VCAP_SERVICES' ) is None ,
11
+ reason = 'requires VCAP_SERVICES' )
12
12
class IntegrationTestCompareComplyV1 (TestCase ):
13
13
compare_comply = None
14
14
15
15
@classmethod
16
16
def setup_class (cls ):
17
- cls .compare_comply = ibm_watson .CompareComplyV1 (
18
- '2018-10-15' )
17
+ cls .compare_comply = ibm_watson .CompareComplyV1 ('2018-10-15' )
19
18
cls .compare_comply .set_default_headers ({
20
- 'X-Watson-Learning-Opt-Out' :
21
- '1' ,
22
- 'X-Watson-Test' :
23
- '1'
19
+ 'X-Watson-Learning-Opt-Out' : '1' ,
20
+ 'X-Watson-Test' : '1'
24
21
})
25
22
26
23
def test_convert_to_html (self ):
@@ -32,7 +29,8 @@ def test_convert_to_html(self):
32
29
def test_classify_elements (self ):
33
30
contract = abspath ('resources/contract_A.pdf' )
34
31
with open (contract , 'rb' ) as file :
35
- result = self .compare_comply .classify_elements (file , file_content_type = 'application/pdf' ).get_result ()
32
+ result = self .compare_comply .classify_elements (
33
+ file , file_content_type = 'application/pdf' ).get_result ()
36
34
assert result is not None
37
35
38
36
def test_extract_tables (self ):
@@ -45,102 +43,97 @@ def test_extract_tables(self):
45
43
def test_compare_documents (self ):
46
44
with open (os .path .join (os .path .dirname (__file__ ), '../../resources/contract_A.pdf' ), 'rb' ) as file1 , \
47
45
open (os .path .join (os .path .dirname (__file__ ), '../../resources/contract_B.pdf' ), 'rb' ) as file2 :
48
- result = self .compare_comply .compare_documents (file1 , file2 ).get_result ()
46
+ result = self .compare_comply .compare_documents (file1 ,
47
+ file2 ).get_result ()
49
48
50
49
assert result is not None
51
50
52
51
@pytest .mark .skip (reason = "Temporarily skip" )
53
52
def test_feedback (self ):
54
53
feedback_data = {
55
- 'feedback_type' : 'element_classification' ,
54
+ 'feedback_type' :
55
+ 'element_classification' ,
56
56
'document' : {
57
57
'hash' : '' ,
58
58
'title' : 'doc title'
59
59
},
60
- 'model_id' : 'contracts' ,
61
- 'model_version' : '11.00' ,
60
+ 'model_id' :
61
+ 'contracts' ,
62
+ 'model_version' :
63
+ '11.00' ,
62
64
'location' : {
63
65
'begin' : '214' ,
64
66
'end' : '237'
65
67
},
66
- 'text' : '1. IBM will provide a Senior Managing Consultant / expert resource, for up to 80 hours, to assist Florida Power & Light (FPL) with the creation of an IT infrastructure unit cost model for existing infrastructure.' ,
68
+ 'text' :
69
+ '1. IBM will provide a Senior Managing Consultant / expert resource, for up to 80 hours, to assist Florida Power & Light (FPL) with the creation of an IT infrastructure unit cost model for existing infrastructure.' ,
67
70
'original_labels' : {
68
- 'types' : [
69
- {
70
- 'label' : {
71
- 'nature' : 'Obligation' ,
72
- 'party' : 'IBM'
73
- },
74
- 'provenance_ids' : [
75
- '85f5981a-ba91-44f5-9efa-0bd22e64b7bc' ,
76
- 'ce0480a1-5ef1-4c3e-9861-3743b5610795'
77
- ]
71
+ 'types' : [{
72
+ 'label' : {
73
+ 'nature' : 'Obligation' ,
74
+ 'party' : 'IBM'
78
75
},
79
- {
80
- 'label' : {
81
- 'nature' : 'End User' ,
82
- 'party' : 'Exclusion'
83
- },
84
- 'provenance_ids' : [
85
- '85f5981a-ba91-44f5-9efa-0bd22e64b7bc' ,
86
- 'ce0480a1-5ef1-4c3e-9861-3743b5610795'
87
- ]
88
- }
89
- ],
90
- 'categories' : [
91
- {
92
- 'label' : 'Responsibilities' ,
93
- 'provenance_ids' : []
76
+ 'provenance_ids' : [
77
+ '85f5981a-ba91-44f5-9efa-0bd22e64b7bc' ,
78
+ 'ce0480a1-5ef1-4c3e-9861-3743b5610795'
79
+ ]
80
+ }, {
81
+ 'label' : {
82
+ 'nature' : 'End User' ,
83
+ 'party' : 'Exclusion'
94
84
},
95
- {
96
- 'label' : 'Amendments' ,
97
- 'provenance_ids' : []
98
- }
99
- ]
85
+ 'provenance_ids' : [
86
+ '85f5981a-ba91-44f5-9efa-0bd22e64b7bc' ,
87
+ 'ce0480a1-5ef1-4c3e-9861-3743b5610795'
88
+ ]
89
+ }],
90
+ 'categories' : [{
91
+ 'label' : 'Responsibilities' ,
92
+ 'provenance_ids' : []
93
+ }, {
94
+ 'label' : 'Amendments' ,
95
+ 'provenance_ids' : []
96
+ }]
100
97
},
101
98
'updated_labels' : {
102
- 'types' : [
103
- {
104
- 'label' : {
105
- 'nature' : 'Obligation' ,
106
- 'party' : 'IBM'
107
- }
108
- },
109
- {
110
- 'label' : {
111
- 'nature' : 'Disclaimer' ,
112
- 'party' : 'Buyer'
113
- }
99
+ 'types' : [{
100
+ 'label' : {
101
+ 'nature' : 'Obligation' ,
102
+ 'party' : 'IBM'
114
103
}
115
- ],
116
- 'categories' : [
117
- {
118
- 'label' : 'Responsibilities'
119
- },
120
- {
121
- 'label' : 'Audits'
104
+ }, {
105
+ 'label' : {
106
+ 'nature' : 'Disclaimer' ,
107
+ 'party' : 'Buyer'
122
108
}
123
- ]
109
+ }],
110
+ 'categories' : [{
111
+ 'label' : 'Responsibilities'
112
+ }, {
113
+ 'label' : 'Audits'
114
+ }]
124
115
}
125
116
}
126
117
127
118
add_feedback = self .compare_comply .add_feedback (
128
- feedback_data ,
129
- user_id = 'wonder woman' ,
119
+ feedback_data , user_id = 'wonder woman' ,
130
120
comment = 'test commment' ).get_result ()
131
121
assert add_feedback is not None
132
122
assert add_feedback ['feedback_id' ] is not None
133
123
feedback_id = add_feedback ['feedback_id' ]
134
124
135
- self .compare_comply .set_default_headers ({'x-watson-metadata' : 'customer_id=sdk-test-customer-id' })
136
- get_feedback = self .compare_comply .get_feedback (feedback_id ).get_result ()
125
+ self .compare_comply .set_default_headers (
126
+ {'x-watson-metadata' : 'customer_id=sdk-test-customer-id' })
127
+ get_feedback = self .compare_comply .get_feedback (
128
+ feedback_id ).get_result ()
137
129
assert get_feedback is not None
138
130
139
131
list_feedback = self .compare_comply .list_feedback (
140
132
feedback_type = 'element_classification' ).get_result ()
141
133
assert list_feedback is not None
142
134
143
- delete_feedback = self .compare_comply .delete_feedback (feedback_id ).get_result ()
135
+ delete_feedback = self .compare_comply .delete_feedback (
136
+ feedback_id ).get_result ()
144
137
assert delete_feedback is not None
145
138
146
139
@pytest .mark .skip (reason = "Temporarily skip" )
@@ -151,12 +144,9 @@ def test_batches(self):
151
144
with open (os .path .join (os .path .dirname (__file__ ), '../../resources/cloud-object-storage-credentials-input.json' ), 'rb' ) as input_credentials_file , \
152
145
open (os .path .join (os .path .dirname (__file__ ), '../../resources/cloud-object-storage-credentials-output.json' ), 'rb' ) as output_credentials_file :
153
146
create_batch = self .compare_comply .create_batch (
154
- 'html_conversion' ,
155
- input_credentials_file ,
156
- 'us-south' ,
147
+ 'html_conversion' , input_credentials_file , 'us-south' ,
157
148
'compare-comply-integration-test-bucket-input' ,
158
- output_credentials_file ,
159
- 'us-south' ,
149
+ output_credentials_file , 'us-south' ,
160
150
'compare-comply-integration-test-bucket-output' ).get_result ()
161
151
162
152
assert create_batch is not None
0 commit comments