コード例 #1
0
 def test_push_xml_event(self):
     data = "<foo>barxml</foo>"
     _input = XMLEvent(data=data)
     self.push.input = _input
     _output = self.pull.output
     self.assertEqual(_output.data_string(), _input.data_string())
     self.assertEqual(_output.event_id, _input.event_id)
     self.assertEqual(_output.meta_id, _input.meta_id)
コード例 #2
0
ファイル: test_zeromq.py プロジェクト: drpoggi/compysition
 def test_push_xml_event(self):
     data = "<foo>barxml</foo>"
     _input = XMLEvent(data=data)
     self.push.input = _input
     _output = self.pull.output
     self.assertEqual(_output.data_string(), _input.data_string())
     self.assertEqual(_output.event_id, _input.event_id)
     self.assertEqual(_output.meta_id, _input.meta_id)
コード例 #3
0
ファイル: test_event.py プロジェクト: drpoggi/compysition
 def test_xml_to_json_single_element_should_force_list(self):
     sample_xml = """
         <root>
             <sample_item force_list="True">
                 <stuff>45</stuff>
             </sample_item>
         </root>
     """
     event = XMLEvent(data=sample_xml)
     json_event = event.convert(JSONEvent)
     assert isinstance(json_event.data['root']['sample_item'], list)
     assert json_event.data['root']['sample_item'][0]['stuff'] == '45'
コード例 #4
0
ファイル: test_event.py プロジェクト: drpoggi/compysition
 def test_xml_to_json_single_element_default_to_dict(self):
     sample_xml = """
         <root>
             <sample_item>
                 <stuff>45</stuff>
             </sample_item>
         </root>
     """
     event = XMLEvent(data=sample_xml)
     json_event = event.convert(JSONEvent)
     assert isinstance(json_event.data['root']['sample_item'], Mapping)
     assert json_event.data['root']['sample_item']['stuff'] == '45'
コード例 #5
0
ファイル: test_event.py プロジェクト: drpoggi/compysition
 def test_xml_to_json_single_element_should_force_list(self):
     sample_xml = """
         <root>
             <sample_item force_list="True">
                 <stuff>45</stuff>
             </sample_item>
         </root>
     """
     event = XMLEvent(data=sample_xml)
     json_event = event.convert(JSONEvent)
     assert isinstance(json_event.data['root']['sample_item'], list)
     assert json_event.data['root']['sample_item'][0]['stuff'] == '45'
コード例 #6
0
ファイル: test_event.py プロジェクト: drpoggi/compysition
 def test_xml_to_json_single_element_default_to_dict(self):
     sample_xml = """
         <root>
             <sample_item>
                 <stuff>45</stuff>
             </sample_item>
         </root>
     """
     event = XMLEvent(data=sample_xml)
     json_event = event.convert(JSONEvent)
     assert isinstance(json_event.data['root']['sample_item'], Mapping)
     assert json_event.data['root']['sample_item']['stuff'] == '45'
コード例 #7
0
ファイル: test_dicttoxml.py プロジェクト: drpoggi/compysition
 def test_event_property_xml_conversion(self):
     _input = XMLEvent(data={"foo": "bar"})
     self.actor.input = _input
     output = self.actor.output
     self.assertRegexpMatches(
         output.data_string(),
         "<propertiestoxml>.*<service>.*<\/service>.*<\/propertiestoxml>")
コード例 #8
0
ファイル: test_event.py プロジェクト: drpoggi/compysition
 def test_xml_to_json_multiple_element_default_to_list(self):
     sample_xml = """
         <root>
             <sample_item>
                 <stuff>45</stuff>
             </sample_item>
             <sample_item>
                 <stuff>45</stuff>
             </sample_item>
             <sample_item>
                 <stuff>45</stuff>
             </sample_item>
         </root>
     """
     event = XMLEvent(data=sample_xml)
     json_event = event.convert(JSONEvent)
     assert isinstance(json_event.data['root']['sample_item'], list)
     assert len(json_event.data['root']['sample_item']) == 3
コード例 #9
0
ファイル: test_event.py プロジェクト: drpoggi/compysition
 def test_xml_to_json_multiple_element_default_to_list(self):
     sample_xml = """
         <root>
             <sample_item>
                 <stuff>45</stuff>
             </sample_item>
             <sample_item>
                 <stuff>45</stuff>
             </sample_item>
             <sample_item>
                 <stuff>45</stuff>
             </sample_item>
         </root>
     """
     event = XMLEvent(data=sample_xml)
     json_event = event.convert(JSONEvent)
     assert isinstance(json_event.data['root']['sample_item'], list)
     assert len(json_event.data['root']['sample_item']) == 3
コード例 #10
0
 def test_multiple_repeated_elements_conversion(self):
     _input = XMLEvent(
         data="<root><foo>bar</foo><foo>bar</foo><foo>bar</foo></root>")
     self.actor.input = _input
     output = self.actor.output
     self.assertEqual(output.data_string(),
                      json.dumps({"root": {
                          "foo": ["bar", "bar", "bar"]
                      }}))
コード例 #11
0
 def test_internal_jsonified_conversion(self):
     _input = XMLEvent(
         data=
         "<jsonified_envelope><errors><foo>bar</foo></errors><errors><foo>bar</foo></errors><errors><foo>bar</foo></errors></jsonified_envelope>"
     )
     self.actor.input = _input
     output = self.actor.output
     self.assertEqual(
         output.data_string(),
         json.dumps(
             {"errors": [{
                 "foo": "bar"
             }, {
                 "foo": "bar"
             }, {
                 "foo": "bar"
             }]}))
コード例 #12
0
 def test_nested_values_conversion(self):
     _input = XMLEvent(
         data=
         "<root><foo><foo><bar>barvalue</bar></foo></foo><fubar>barfu</fubar></root>"
     )
     self.actor.input = _input
     output = self.actor.output
     self.assertEqual(
         output.data_string(),
         json.dumps({
             "root": {
                 "foo": {
                     "foo": {
                         "bar": "barvalue"
                     }
                 },
                 "fubar": "barfu"
             }
         }))
コード例 #13
0
ファイル: test_event.py プロジェクト: drpoggi/compysition
 def test_conversion_classes(self):
     current_conversion_classes = XMLEvent().conversion_methods.keys()
     assert len(current_conversion_classes) == len(conversion_classes)
     for cur_conv_meth in current_conversion_classes:
         assert cur_conv_meth in conversion_classes
コード例 #14
0
ファイル: test_xsd.py プロジェクト: drpoggi/compysition
 def test_valid_xml(self):
     _input = XMLEvent(data=valid_xml)
     self.actor.input = _input
     _output = self.actor.output
     self.assertEqual(_input.data_string(), _output.data_string())
コード例 #15
0
ファイル: test_dicttoxml.py プロジェクト: drpoggi/compysition
 def test_xml_event_class_consistency(self):
     _input = XMLEvent(data={"foo": "bar"})
     self.actor.input = _input
     output = self.actor.output
     self.assertEqual(output.__class__, XMLEvent)
     self.assertEqual(output.data_string(), "<foo>bar</foo>")
コード例 #16
0
ファイル: test_xsd.py プロジェクト: drpoggi/compysition
 def test_valid_xml(self):
     _input = XMLEvent(data=valid_xml)
     self.actor.input = _input
     _output = self.actor.output
     self.assertEqual(_input.data_string(), _output.data_string())
コード例 #17
0
ファイル: test_xsd.py プロジェクト: drpoggi/compysition
 def test_invalid_xml(self):
     _input = XMLEvent(data=invalid_xml)
     self.actor.input = _input
     _output = self.actor.error
     self.assertTrue(isinstance(_output.error, MalformedEventData))
コード例 #18
0
 def test_single_root_dict_conversion(self):
     _input = XMLEvent(data="<foo>bar</foo>")
     self.actor.input = _input
     output = self.actor.output
     self.assertEqual(output.data_string(), json.dumps({"foo": "bar"}))