<commit_before>#!/usr/bin/env python

"""
@package ion.agents.platform.test.test_platform_agent_with_rsn
@file    ion/agents/platform/test/test_platform_agent_with_rsn.py
@author  <NAME>
@brief   Test cases for platform agent interacting with RSN
"""

__author__ = '<NAME>'
__license__ = 'Apache 2.0'

# The following can be prefixed with PLAT_NETWORK=single to exercise the tests
# with a single platform (with no sub-platforms). Otherwise a small network is
# used. See HelperTestMixin.
#
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_capabilities
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_some_state_transitions
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_get_set_resources
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_some_commands
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_resource_monitoring
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_external_event_dispatch
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_connect_disconnect_instrument
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_check_sync
#


from pyon.public import log

from pyon.util.containers import get_ion_ts

from interface.objects import AgentCommand
from interface.objects import CapabilityType
from interface.objects import AgentCapability

from ion.agents.platform.platform_agent import PlatformAgentState
from ion.agents.platform.platform_agent import PlatformAgentEvent
from ion.agents.platform.responses import NormalResponse

from ion.agents.platform.test.base_test_platform_agent_with_rsn import BaseIntTestPlatform

from mock import patch
from pyon.public import CFG


@patch.dict(CFG, {'endpoint': {'receive': {'timeout': 180}}})
class TestPlatformAgent(BaseIntTestPlatform):

    def _create_network_and_start_root_platform(self):
        """
        Call this at the beginning of each test. We need to make sure that
        the patched timeout is in effect for the actions performed here.

        @note this used to be done in setUp, but the patch.dict mechanism does
        *not* take effect in setUp!
        """

        # NOTE The tests expect to use values set up by HelperTestMixin for
        # for the following networks (see ion/agents/platform/test/helper.py)
        if self.PLATFORM_ID == 'Node1D':
            self.p_root = self._create_small_hierarchy()

        elif self.PLATFORM_ID == 'LJ01D':
            self.p_root = self._create_single_platform()

        else:
            self.fail("self.PLATFORM_ID expected to be one of: 'Node1D', 'LJ01D'")

        self._start_platform(self.p_root)

    def tearDown(self):
        if self.p_root:<commit_msg>make sure self.p_root is defined<commit_after>#!/usr/bin/env python

"""
@package ion.agents.platform.test.test_platform_agent_with_rsn
@file    ion/agents/platform/test/test_platform_agent_with_rsn.py
@author  <NAME>
@brief   Test cases for platform agent interacting with RSN
"""

__author__ = '<NAME>'
__license__ = 'Apache 2.0'

# The following can be prefixed with PLAT_NETWORK=single to exercise the tests
# with a single platform (with no sub-platforms). Otherwise a small network is
# used. See HelperTestMixin.
#
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_capabilities
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_some_state_transitions
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_get_set_resources
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_some_commands
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_resource_monitoring
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_external_event_dispatch
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_connect_disconnect_instrument
# bin/nosetests -sv ion/agents/platform/test/test_platform_agent_with_rsn.py:TestPlatformAgent.test_check_sync
#


from pyon.public import log

from pyon.util.containers import get_ion_ts

from interface.objects import AgentCommand
from interface.objects import CapabilityType
from interface.objects import AgentCapability

from ion.agents.platform.platform_agent import PlatformAgentState
from ion.agents.platform.platform_agent import PlatformAgentEvent
from ion.agents.platform.responses import NormalResponse

from ion.agents.platform.test.base_test_platform_agent_with_rsn import BaseIntTestPlatform

from mock import patch
from pyon.public import CFG


@patch.dict(CFG, {'endpoint': {'receive': {'timeout': 180}}})
class TestPlatformAgent(BaseIntTestPlatform):

    def _create_network_and_start_root_platform(self):
        """
        Call this at the beginning of each test. We need to make sure that
        the patched timeout is in effect for the actions performed here.

        @note this used to be done in setUp, but the patch.dict mechanism does
        *not* take effect in setUp!
        """
        self.p_root = None

        # NOTE The tests expect to use values set up by HelperTestMixin for
        # for the following networks (see ion/agents/platform/test/helper.py)
        if self.PLATFORM_ID == 'Node1D':
            self.p_root = self._create_small_hierarchy()

        elif self.PLATFORM_ID == 'LJ01D':
            self.p_root = self._create_single_platform()

        else:
            self.fail("self.PLATFORM_ID expected to be one of: 'Node1D', 'LJ01D'")

        self._start_platform(self.p_root)

    def tearDown(self):
        if self.p_root:
{'fraction_non_alphanumeric': 0.08093346573982126, 'fraction_numerical': 0.003641178417742469, 'mean_word_length': 4.626629422718808, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '674124', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1847, 'n_words': 425}