@@ -136,11 +136,49 @@ def test_sequence_id_mismatch(self):
136
136
137
137
138
138
class TestXMLtoEBUTTDAdapter (TestCase ):
139
- _output_type = documents .EBUTTDDocument
140
139
_adapter_class = document_data .XMLtoEBUTTDAdapter
141
- _expected_keys = []
140
+ _test_xml_file = 'testEbuttd.xml'
141
+ _test_data_dir_path = os .path .join (os .path .dirname (__file__ ), 'test_data' )
142
+ _test_xml_path = os .path .join (_test_data_dir_path , _test_xml_file )
143
+ _output_type = documents .EBUTTDDocument
144
+ _expected_keys = [
145
+ 'raw_xml'
146
+ ]
147
+ instance = None
148
+
149
+ def setUp (self ):
150
+ self .instance = self ._adapter_class ()
151
+ self .assertIsInstance (self .instance , IDocumentDataAdapter )
142
152
143
- # TODO: Finish this once we have EBUTT-D parsing
153
+ def _assert_output_type (self , result ):
154
+ self .assertIsInstance (result , self ._output_type )
155
+
156
+ def _assert_kwargs_passtrough (self , result_kwargs , expected_keys ):
157
+ self .assertEqual (set (result_kwargs .keys ()), set (expected_keys ))
158
+
159
+ def _get_xml (self ):
160
+ with open (self ._test_xml_path , 'r' ) as xml_file :
161
+ xml_data = xml_file .read ()
162
+ return xml_data
163
+
164
+ def _get_input (self ):
165
+ return self ._get_xml ()
166
+
167
+ def test_success (self ):
168
+ expected_keys = []
169
+ expected_keys .extend (self ._expected_keys )
170
+ result , res_kwargs = self .instance .convert_data (self ._get_input ())
171
+ self ._assert_output_type (result )
172
+ self ._assert_kwargs_passtrough (res_kwargs , expected_keys )
173
+
174
+ def test_kwargs_passthrough (self ):
175
+ in_kwargs = {
176
+ 'foo' : 'bar'
177
+ }
178
+ expected_keys = ['foo' ]
179
+ expected_keys .extend (self ._expected_keys )
180
+ result , res_kwargs = self .instance .convert_data (self ._get_input (), ** in_kwargs )
181
+ self ._assert_kwargs_passtrough (res_kwargs , expected_keys )
144
182
145
183
146
184
class TestEBUTT3toXMLAdapter (TestXMLtoEBUTT3Adapter ):
@@ -164,20 +202,18 @@ def test_sequence_id_match(self):
164
202
pass
165
203
166
204
167
- class TestEBUTTDtoXMLAdapter (TestEBUTT3toXMLAdapter ):
205
+ class TestEBUTTDtoXMLAdapter (TestXMLtoEBUTTDAdapter ):
206
+ _output_type = six .text_type
168
207
_adapter_class = document_data .EBUTTDtoXMLAdapter
169
208
_expected_keys = []
170
209
210
+ def _get_input (self ):
211
+ return documents .EBUTTDDocument .create_from_xml (self ._get_xml ())
212
+
171
213
def _get_input (self ):
172
214
input_doc = documents .EBUTTDDocument (lang = 'en-GB' )
173
215
return input_doc
174
216
175
- def test_sequence_id_mismatch (self ):
176
- pass
177
-
178
- def test_sequence_id_match (self ):
179
- pass
180
-
181
217
182
218
class TestEBUTT3toEBUTTDAdapter (TestXMLtoEBUTT3Adapter ):
183
219
_adapter_class = document_data .EBUTT3toEBUTTDAdapter
0 commit comments