#!/usr/bin/env python
# -- Content-Encoding: UTF-8 --
"""
Tests the iPOPO @HiddenProperty decorator.

:author: Thomas Calmant
"""

# Standard library
import random
try:
    import unittest2 as unittest
except ImportError:
    import unittest

# Pelix
from pelix.framework import FrameworkFactory
from pelix.ipopo.constants import use_ipopo

# Tests
from tests.ipopo import install_bundle, install_ipopo

# ------------------------------------------------------------------------------

__version_info__ = (1, 0, 1)
__version__ = ".".join(str(x) for x in __version_info__)

NAME_A = "componentA"

# ------------------------------------------------------------------------------


class HiddenPropTest(unittest.TestCase):
    """
    Tests the "hidden property" behavior
    """
    def setUp(self):
        """
        Called before each test. Initiates a framework.
        """
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
        self.ipopo = install_ipopo(self.framework)

        # Install the test bundle
        self.module = install_bundle(self.framework)

    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework()

    def test_hidden_default(self):
        """
        Tests the hidden property
        """
        context = self.framework.get_bundle_context()

        # Instantiate the component
        with use_ipopo(context) as ipopo:
            svc = ipopo.instantiate(self.module.FACTORY_HIDDEN_PROPS, NAME_A)

        # Check default values (and accesses)
        self.assertEqual(svc.hidden, "hidden")
        self.assertEqual(svc.public, "public")

        # Check instance details
        with use_ipopo(context) as ipopo:
            details = ipopo.get_instance_details(NAME_A)

        self.assertNotIn("hidden.prop", details["properties"])

    def test_hidden_instantiate(self):
        """
        Tests the value of hidden properties given as instantiation parameters
        """
        context = self.framework.get_bundle_context()

        # Prepare random values
        hidden_value =  random.randint(0, 100)
        public_value = random.randint(0, 100)

        # Instantiate the component
        with use_ipopo(context) as ipopo:
            svc = ipopo.instantiate(self.module.FACTORY_HIDDEN_PROPS, NAME_A,
                                    {"hidden.prop": hidden_value,
                                     "public.prop": public_value})

        # Check default values (and accesses)
        self.assertEqual(svc.hidden, hidden_value)
        self.assertEqual(svc.public, public_value)

        # Check instance details
        with use_ipopo(context) as ipopo:
            details = ipopo.get_instance_details(NAME_A)

        self.assertNotIn("hidden.prop", details["properties"])

# ------------------------------------------------------------------------------

if __name__ == "__main__":
    # Set logging level
    import logging
    logging.basicConfig(level=logging.DEBUG)
    unittest.main()

c0e53047fa35c8621f34d1bcd52fb5241540b549
<mask token>

<mask token>


class HiddenPropTest(unittest.TestCase):
    <mask token>

    def setUp(self):
        """
        Called before each test. Initiates a framework.
        """
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
        self.ipopo = install_ipopo(self.framework)
        self.module = install_bundle(self.framework)

    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework()

    def test_hidden_default(self):
        """
        Tests the hidden property
        """
        context = self.framework.get_bundle_context()
        with use_ipopo(context) as ipopo:
            svc = ipopo.instantiate(self.module.FACTORY_HIDDEN_PROPS, NAME_A)
        self.assertEqual(svc.hidden, 'hidden')
        self.assertEqual(svc.public, 'public')
        with use_ipopo(context) as ipopo:
            details = ipopo.get_instance_details(NAME_A)
        self.assertNotIn('hidden.prop', details['properties'])
    <mask token>


<mask token>

<mask token>
try:
    import unittest2 as unittest
except ImportError:
    import unittest
<mask token>


class HiddenPropTest(unittest.TestCase):
    """
    Tests the "hidden property" behavior
    """

    def setUp(self):
        """
        Called before each test. Initiates a framework.
        """
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
        self.ipopo = install_ipopo(self.framework)
        self.module = install_bundle(self.framework)

    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework()

    def test_hidden_default(self):
        """
        Tests the hidden property
        """
        context = self.framework.get_bundle_context()
        with use_ipopo(context) as ipopo:
            svc = ipopo.instantiate(self.module.FACTORY_HIDDEN_PROPS, NAME_A)
        self.assertEqual(svc.hidden, 'hidden')
        self.assertEqual(svc.public, 'public')
        with use_ipopo(context) as ipopo:
            details = ipopo.get_instance_details(NAME_A)
        self.assertNotIn('hidden.prop', details['properties'])

    def test_hidden_instantiate(self):
        """
        Tests the value of hidden properties given as instantiation parameters
        """
        context = self.framework.get_bundle_context()
        hidden_value = random.randint(0, 100)
        public_value = random.randint(0, 100)
        with use_ipopo(context) as ipopo:
            svc = ipopo.instantiate(self.module.FACTORY_HIDDEN_PROPS,
                NAME_A, {'hidden.prop': hidden_value, 'public.prop':
                public_value})
        self.assertEqual(svc.hidden, hidden_value)
        self.assertEqual(svc.public, public_value)
        with use_ipopo(context) as ipopo:
            details = ipopo.get_instance_details(NAME_A)
        self.assertNotIn('hidden.prop', details['properties'])


if __name__ == '__main__':
    import logging
    logging.basicConfig(level=logging.DEBUG)
    unittest.main()

<mask token>
import random
try:
    import unittest2 as unittest
except ImportError:
    import unittest
from pelix.framework import FrameworkFactory
from pelix.ipopo.constants import use_ipopo
from tests.ipopo import install_bundle, install_ipopo
__version_info__ = 1, 0, 1
__version__ = '.'.join(str(x) for x in __version_info__)
NAME_A = 'componentA'


class HiddenPropTest(unittest.TestCase):
    """
    Tests the "hidden property" behavior
    """

    def setUp(self):
        """
        Called before each test. Initiates a framework.
        """
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
        self.ipopo = install_ipopo(self.framework)
        self.module = install_bundle(self.framework)

    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework()

    def test_hidden_default(self):
        """
        Tests the hidden property
        """
        context = self.framework.get_bundle_context()
        with use_ipopo(context) as ipopo:
            svc = ipopo.instantiate(self.module.FACTORY_HIDDEN_PROPS, NAME_A)
        self.assertEqual(svc.hidden, 'hidden')
        self.assertEqual(svc.public, 'public')
        with use_ipopo(context) as ipopo:
            details = ipopo.get_instance_details(NAME_A)
        self.assertNotIn('hidden.prop', details['properties'])

    def test_hidden_instantiate(self):
        """
        Tests the value of hidden properties given as instantiation parameters
        """
        context = self.framework.get_bundle_context()
        hidden_value = random.randint(0, 100)
        public_value = random.randint(0, 100)
        with use_ipopo(context) as ipopo:
            svc = ipopo.instantiate(self.module.FACTORY_HIDDEN_PROPS,
                NAME_A, {'hidden.prop': hidden_value, 'public.prop':
                public_value})
        self.assertEqual(svc.hidden, hidden_value)
        self.assertEqual(svc.public, public_value)
        with use_ipopo(context) as ipopo:
            details = ipopo.get_instance_details(NAME_A)
        self.assertNotIn('hidden.prop', details['properties'])


if __name__ == '__main__':
    import logging
    logging.basicConfig(level=logging.DEBUG)
    unittest.main()

#!/usr/bin/env python
# -- Content-Encoding: UTF-8 --
"""
Tests the iPOPO @HiddenProperty decorator.

:author: Thomas Calmant
"""

# Standard library
import random
try:
    import unittest2 as unittest
except ImportError:
    import unittest

# Pelix
from pelix.framework import FrameworkFactory
from pelix.ipopo.constants import use_ipopo

# Tests
from tests.ipopo import install_bundle, install_ipopo

# ------------------------------------------------------------------------------

__version_info__ = (1, 0, 1)
__version__ = ".".join(str(x) for x in __version_info__)

NAME_A = "componentA"

# ------------------------------------------------------------------------------


class HiddenPropTest(unittest.TestCase):
    """
    Tests the "hidden property" behavior
    """
    def setUp(self):
        """
        Called before each test. Initiates a framework.
        """
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
        self.ipopo = install_ipopo(self.framework)

        # Install the test bundle
        self.module = install_bundle(self.framework)

    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework()

    def test_hidden_default(self):
        """
        Tests the hidden property
        """
        context = self.framework.get_bundle_context()

        # Instantiate the component
        with use_ipopo(context) as ipopo:
            svc = ipopo.instantiate(self.module.FACTORY_HIDDEN_PROPS, NAME_A)

        # Check default values (and accesses)
        self.assertEqual(svc.hidden, "hidden")
        self.assertEqual(svc.public, "public")

        # Check instance details
        with use_ipopo(context) as ipopo:
            details = ipopo.get_instance_details(NAME_A)

        self.assertNotIn("hidden.prop", details["properties"])

    def test_hidden_instantiate(self):
        """
        Tests the value of hidden properties given as instantiation parameters
        """
        context = self.framework.get_bundle_context()

        # Prepare random values
        hidden_value =  random.randint(0, 100)
        public_value = random.randint(0, 100)

        # Instantiate the component
        with use_ipopo(context) as ipopo:
            svc = ipopo.instantiate(self.module.FACTORY_HIDDEN_PROPS, NAME_A,
                                    {"hidden.prop": hidden_value,
                                     "public.prop": public_value})

        # Check default values (and accesses)
        self.assertEqual(svc.hidden, hidden_value)
        self.assertEqual(svc.public, public_value)

        # Check instance details
        with use_ipopo(context) as ipopo:
            details = ipopo.get_instance_details(NAME_A)

        self.assertNotIn("hidden.prop", details["properties"])

# ------------------------------------------------------------------------------

if __name__ == "__main__":
    # Set logging level
    import logging
    logging.basicConfig(level=logging.DEBUG)
    unittest.main()
