def test_remove_from_hardware_isMock(): """ verify call to remove hardware when isMock = True """ _isMock = True mock_handler = MagicMock() mock_handler.device_id = MOCK_HANDLER_DEVICE_ID ogp = OnuGemPort(mock_handler, GEM_DATA, ALLOCID, TECHPROFILEID, UNIID, ENTITYID, MULTICAST, TRAFFICCLASS, _isMock) result = yield ogp.remove_from_hardware('fake') assert result == 'mock'
def test_onu_gem_port_init_values_missing(): """ verify __init__ fails when no values are specified """ with pytest.raises(Exception): OnuGemPort()
def ogp(): mock_handler = MagicMock() mock_handler.device_id = MOCK_HANDLER_DEVICE_ID ogp_obj = OnuGemPort.create(mock_handler, GEM_DATA, ALLOCID, TECHPROFILEID, UNIID, ENTITYID) return ogp_obj
def ogp_exception(mock_handler): try: ogp_obj = OnuGemPort(mock_handler, GEM_DATA_BAD_UNI_ID, ALLOCID, TECHPROFILEID, UNIID, ENTITYID) except: raise return ogp_obj
def test_onu_gem_port_create(patched_get_logger): """ verify call to create(). Equivalent to creating OnuGemPort with defaults so a 'defaults' test is not needed. """ mock_handler = MagicMock() mock_handler.device_id = MOCK_HANDLER_DEVICE_ID ogp = OnuGemPort.create(mock_handler, GEM_DATA, ALLOCID, TECHPROFILEID, UNIID, ENTITYID) patched_get_logger.assert_called_once_with( device_id=MOCK_HANDLER_DEVICE_ID, gem_id=GEM_DATA.get('gemport-id')) assert ogp.gem_id == GEM_DATA.get('gemport-id') assert ogp._alloc_id == ALLOCID # assert ogp_full.tech_profile_id == TECHPROFILEID assert ogp.tech_profile_id is None # TODO: code says default may change to a property assert ogp.encryption == GEM_DATA.get('encryption') # uses a getter assert ogp.multicast is False assert ogp.traffic_class is None assert ogp._handler == mock_handler assert ogp._is_mock is False assert ogp._gem_data == GEM_DATA assert ogp._entity_id == ENTITYID assert ogp.entity_id == ENTITYID assert ogp._tcont_entity_id is None assert ogp._interworking is False assert ogp.uni_id == GEM_DATA['uni-id'] assert ogp.direction == GEM_DATA.get('direction') assert ogp._pbit_map == GEM_DATA.get('pbit-map')[2:] assert ogp.pbit_map == GEM_DATA.get('pbit-map')[2:] assert ogp.priority_q == GEM_DATA.get('priority-q') assert ogp._max_q_size == GEM_DATA.get('max-q-size') assert ogp.max_q_size == GEM_DATA.get('max-q-size') assert ogp.weight == GEM_DATA.get('weight') assert ogp._discard_config == GEM_DATA.get('discard-config') assert ogp.discard_config == GEM_DATA.get('discard-config') assert ogp._discard_policy == GEM_DATA.get('discard-policy') assert ogp.discard_policy == GEM_DATA.get('discard-policy') assert ogp._scheduling_policy == GEM_DATA.get('scheduling-policy') assert ogp.scheduling_policy == GEM_DATA.get('scheduling-policy')
def ogp_defaults(mock_handler): ogp_obj = OnuGemPort(mock_handler, GEM_DATA, ALLOCID, TECHPROFILEID, UNIID, ENTITYID) return ogp_obj
def ogp_full(mock_handler): ogp_obj = OnuGemPort(mock_handler, GEM_DATA, ALLOCID, TECHPROFILEID, UNIID, ENTITYID, MULTICAST, TRAFFICCLASS, ISMOCK) return ogp_obj