#import unittest

@attr('UNIT', group='sa')
class TestInstrumentManagement(PyonTestCase):

    def setUp(self):
        self.mock_ionobj = self._create_IonObject_mock('ion.services.sa.instrument.instrument_management_service.IonObject')
        #self.mock_ionobj = IonObject
        mock_clients = self._create_service_mock('instrument_management_service')

        self.instrument_mgmt_service = InstrumentManagementService()
        self.instrument_mgmt_service.clients = mock_clients
        
        # must call this manually
        self.instrument_mgmt_service.on_init()

rwm = ResourceImplMetatest(TestInstrumentManagement, InstrumentManagementService, log)

rwm.add_resource_impl_unittests(InstrumentAgentInstanceImpl, {"exchange-name": "rhubarb"})
rwm.add_resource_impl_unittests(InstrumentAgentImpl, {"agent_version": "3", "time_source": "the universe"})
rwm.add_resource_impl_unittests(InstrumentDeviceImpl, {"serialnumber": "123", "firmwareversion": "x"})
rwm.add_resource_impl_unittests(InstrumentModelImpl, {"model": "redundant?", "weight": 20000})
rwm.add_resource_impl_unittests(PlatformAgentInstanceImpl, {"exchange-name": "sausage"})
rwm.add_resource_impl_unittests(PlatformAgentImpl, {"tbd": "the big donut"})
rwm.add_resource_impl_unittests(PlatformDeviceImpl, {"serial_number": "2345"})
rwm.add_resource_impl_unittests(PlatformModelImpl, {"tbd": "tammy breathed deeply"})
rwm.add_resource_impl_unittests(SensorDeviceImpl, {"serialnumber": "123"})
rwm.add_resource_impl_unittests(SensorModelImpl, {"model": "redundant field?", "weight": 2})


@attr('UNIT', group='sa')
class TestMarineFacilityManagement(PyonTestCase):

    def setUp(self):
        self.mock_ionobj = self._create_IonObject_mock('ion.services.sa.marine_facility.marine_facility_management_service.IonObject')
        
        #self.mock_ionobj = IonObject
        mock_clients = self._create_service_mock('marine_facility_management')

        self.marine_facility_mgmt_service = MarineFacilityManagementService()
        self.marine_facility_mgmt_service.clients = mock_clients
        
        # must call this manually
        self.marine_facility_mgmt_service.on_init()



    def test_assign_instrument(self):
        self.marine_facility_mgmt_service.assign_instrument('111', '222')

        self.marine_facility_mgmt_service.clients.resource_registry.create_association.assert_called_once_with('222', AT.hasInstrument, '111', None)

rwm = ResourceImplMetatest(TestMarineFacilityManagement, MarineFacilityManagementService, log)

rwm.add_resource_impl_unittests(LogicalInstrumentImpl, {})
rwm.add_resource_impl_unittests(LogicalPlatformImpl, {"buoyname": "steve", "buoyheight": "3"})
rwm.add_resource_impl_unittests(MarineFacilityImpl, {})
rwm.add_resource_impl_unittests(SiteImpl, {})