Example #1
0
 def test_createFeed( self, config ):
     options = None
     cs = COSMSend( options )
     device = 'device 1'
     port = 'port 1'
     config.assert_called_once_with()
     cs.config = self.config_data
     data = {'device': device,
             'port': port,
             Constants.DataPacket.arrival_time: datetime.datetime( 2012, 1, 2, 3, 4, 5 ),
             Constants.DataPacket.current_value: 10}
     cs.createDataStream( device, port, data )
     feed = cs.createFeed( data, device, port )
     pprint.pprint( feed )
     self.assertEqual( feed[Constants.Cosm.title], Constants.Cosm.title )
     self.assertEqual( feed[Constants.Cosm.status], Constants.Cosm.status )
     self.assertEqual( feed[Constants.Cosm.creator], Constants.Cosm.creator )
     self.assertEqual( feed[Constants.Cosm.created], Constants.Cosm.created )
     self.assertEqual( feed[Constants.Cosm.feed], 'url' )
     self.assertEqual( feed[Constants.Cosm.email], Constants.Cosm.email )
     self.assertEqual( feed[Constants.Cosm.id], Constants.Cosm.id )
     self.assertEqual( feed[Constants.Cosm.auto_feed_url], ( 'url', ) )
     self.assertEqual( feed[Constants.Cosm.version], Constants.Cosm.version )
     cs.empty_datastream_list()
     cs = None
Example #2
0
 def test_createFeed(self, config):
     options = None
     cs = COSMSend(options)
     device = 'device 1'
     port = 'port 1'
     config.assert_called_once_with()
     cs.config = self.config_data
     data = {
         'device':
         device,
         'port':
         port,
         Constants.DataPacket.arrival_time:
         datetime.datetime(2012, 1, 2, 3, 4, 5),
         Constants.DataPacket.current_value:
         10
     }
     cs.createDataStream(device, port, data)
     feed = cs.createFeed(data, device, port)
     pprint.pprint(feed)
     self.assertEqual(feed[Constants.Cosm.title], Constants.Cosm.title)
     self.assertEqual(feed[Constants.Cosm.status], Constants.Cosm.status)
     self.assertEqual(feed[Constants.Cosm.creator], Constants.Cosm.creator)
     self.assertEqual(feed[Constants.Cosm.created], Constants.Cosm.created)
     self.assertEqual(feed[Constants.Cosm.feed], 'url')
     self.assertEqual(feed[Constants.Cosm.email], Constants.Cosm.email)
     self.assertEqual(feed[Constants.Cosm.id], Constants.Cosm.id)
     self.assertEqual(feed[Constants.Cosm.auto_feed_url], ('url', ))
     self.assertEqual(feed[Constants.Cosm.version], Constants.Cosm.version)
     cs.empty_datastream_list()
     cs = None
Example #3
0
 def test_createFeed_with_no_port_in_config_file( self, config ):
     options = None
     cs = COSMSend( options )
     device = 'device 1'
     port = 'port'
     config.assert_called_once_with()
     cs.config = self.config_data
     data = {
             Constants.DataPacket.device: device,
             Constants.DataPacket.arrival_time: datetime.datetime( 2012, 1, 2, 3, 4, 5 ),
             Constants.DataPacket.current_value: 10}
     with self.assertRaisesRegexp( KeyError, 'Port is not in cosm configuration file:.*' ):
         feed = cs.createFeed( data, device, port )
     cs = None
Example #4
0
 def test_createFeed_with_no_port_in_config_file(self, config):
     options = None
     cs = COSMSend(options)
     device = 'device 1'
     port = 'port'
     config.assert_called_once_with()
     cs.config = self.config_data
     data = {
         Constants.DataPacket.device:
         device,
         Constants.DataPacket.arrival_time:
         datetime.datetime(2012, 1, 2, 3, 4, 5),
         Constants.DataPacket.current_value:
         10
     }
     with self.assertRaisesRegexp(
             KeyError, 'Port is not in cosm configuration file:.*'):
         feed = cs.createFeed(data, device, port)
     cs = None