<commit_before>#!/usr/bin/env python
'''
@author <NAME>
@date Thu May  2 13:19:39 EDT 2013
@file ion/services/dm/test/test_instrument_integration.py
@description Integration Test that verifies instrument streaming through DM
'''

from ion.services.dm.test.dm_test_case import DMTestCase, FakeProcess
from ion.agents.port.port_agent_process import PortAgentProcessType, PortAgentType
from ion.services.sa.test.helpers import AgentProcessStateGate
from pyon.public import RT, IonObject, CFG
from interface.objects import StreamConfiguration, ProcessStateEnum, AgentCommand
from nose.plugins.attrib import attr
from pyon.agent.agent import ResourceAgentClient, ResourceAgentState, ResourceAgentEvent
import ion.agents.instrument.test.test_instrument_agent
from mi.instrument.seabird.sbe37smb.ooicore.driver import SBE37ProtocolEvent
from ion.services.dm.test.test_dm_end_2_end import DatasetMonitor
from ion.services.dm.utility.granule import RecordDictionaryTool
import unittest
import os

@attr('INT', group='dm')
class TestInstrumentIntegration(DMTestCase):

    def create_instrument_model(self):
        # Create InstrumentModel
        instModel_obj = IonObject(RT.InstrumentModel,
                                  name='SBE37IMModel',
                                  description="SBE37IMModel")
        instrument_model_id = self.instrument_management.create_instrument_model(instModel_obj)
        self.addCleanup(self.instrument_management.delete_instrument_model, instrument_model_id)
        return instrument_model_id

    def create_instrument_agent(self, instrument_model_id):
        raw_config = StreamConfiguration(stream_name='raw', parameter_dictionary_name='raw')
        parsed_config = StreamConfiguration(stream_name='parsed', parameter_dictionary_name='ctd_parsed_param_dict')
        # Create InstrumentAgent
        instagent_obj = IonObject(RT.InstrumentAgent,
                                  name='agent007',
                                  description="SBE37IMAgent",
                                  driver_uri="http://sddevrepo.oceanobservatories.org/releases/seabird_sbe37smb_ooicore-0.0.1a-py2.7.egg",
                                  stream_configurations = [raw_config, parsed_config])
        instrument_agent_id = self.instrument_management.create_instrument_agent(instagent_obj)
        self.addCleanup(self.instrument_management.delete_instrument_agent, instrument_agent_id)
        self.instrument_management.assign_instrument_model_to_instrument_agent(instrument_model_id, instrument_agent_id)
        return instrument_agent_id

    def create_instrument_device(self, instrument_model_id):
        instDevice_obj = IonObject(RT.InstrumentDevice,
                                   name='SBE37IMDevice',
                                   description="SBE37IMDevice",
                                   serial_number="12345" )<commit_msg>Don't use hard-coded link to egg, use master reference<commit_after>#!/usr/bin/env python
'''
@author <NAME>
@date Thu May  2 13:19:39 EDT 2013
@file ion/services/dm/test/test_instrument_integration.py
@description Integration Test that verifies instrument streaming through DM
'''

from ion.services.dm.test.dm_test_case import DMTestCase, FakeProcess
from ion.agents.port.port_agent_process import PortAgentProcessType, PortAgentType
from ion.services.sa.test.helpers import AgentProcessStateGate
from pyon.public import RT, IonObject, CFG
from interface.objects import StreamConfiguration, ProcessStateEnum, AgentCommand
from nose.plugins.attrib import attr
from pyon.agent.agent import ResourceAgentClient, ResourceAgentState, ResourceAgentEvent
import ion.agents.instrument.test.test_instrument_agent
from ion.agents.instrument.test.test_instrument_agent import DRV_URI_GOOD
from mi.instrument.seabird.sbe37smb.ooicore.driver import SBE37ProtocolEvent
from ion.services.dm.test.test_dm_end_2_end import DatasetMonitor
from ion.services.dm.utility.granule import RecordDictionaryTool
import unittest
import os

@attr('INT', group='dm')
class TestInstrumentIntegration(DMTestCase):

    def create_instrument_model(self):
        # Create InstrumentModel
        instModel_obj = IonObject(RT.InstrumentModel,
                                  name='SBE37IMModel',
                                  description="SBE37IMModel")
        instrument_model_id = self.instrument_management.create_instrument_model(instModel_obj)
        self.addCleanup(self.instrument_management.delete_instrument_model, instrument_model_id)
        return instrument_model_id

    def create_instrument_agent(self, instrument_model_id):
        raw_config = StreamConfiguration(stream_name='raw', parameter_dictionary_name='raw')
        parsed_config = StreamConfiguration(stream_name='parsed', parameter_dictionary_name='ctd_parsed_param_dict')
        # Create InstrumentAgent
        instagent_obj = IonObject(RT.InstrumentAgent,
                                  name='agent007',
                                  description="SBE37IMAgent",
                                  driver_uri=DRV_URI_GOOD,
                                  stream_configurations = [raw_config, parsed_config])
        instrument_agent_id = self.instrument_management.create_instrument_agent(instagent_obj)
        self.addCleanup(self.instrument_management.delete_instrument_agent, instrument_agent_id)
        self.instrument_management.assign_instrument_model_to_instrument_agent(instrument_model_id, instrument_agent_id)
        return instrument_agent_id

    def create_instrument_device(self, instrument_model_id):
        instDevice_obj = IonObject(RT.InstrumentDevice,
                                   name='SBE37IMDevice',
                                   description="SBE37IMDevice",
                                   serial_number="12345" )
{'fraction_non_alphanumeric': 0.06856158484065461, 'fraction_numerical': 0.012919896640826873, 'mean_word_length': 3.4524539877300615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7315156', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1551, 'n_words': 270}