# Path: netman/core/objects/port_modes.py
# BOND_MEMBER = "BOND_MEMBER"


from hamcrest import is_, assert_that, empty, none
from netman.core.objects.exceptions import UnknownInterface
from netman.core.objects.port_modes import BOND_MEMBER
from tests.adapters.compliance_test_case import ComplianceTestCase


class AddInterfaceToBondTest(ComplianceTestCase):
    _dev_sample = "juniper"

    def setUp(self):
        super(AddInterfaceToBondTest, self).setUp()
        self.client.add_bond(42)

    def tearDown(self):
        self.janitor.remove_bond(42)
        super(AddInterfaceToBondTest, self).tearDown()

    def test_sets_the_interface_bond_master(self):
        self.client.add_interface_to_bond(self.test_port, 42)
        interface = self.client.get_interface(self.test_port)

        assert_that(interface.bond_master, is_(42))

        self.janitor.remove_interface_from_bond(self.test_port)

    def test_sets_the_interface_port_mode_to_bond_members(self):
        self.client.add_interface_to_bond(self.test_port, 42)
        interface = self.client.get_interface(self.test_port)


# Path: netman/core/objects/port_modes.py
# BOND_MEMBER = "BOND_MEMBER"


# Path: tests/adapters/compliance_tests/add_interface_to_bond_test.py
from hamcrest import is_, assert_that, empty, none
from netman.core.objects.exceptions import UnknownInterface
from netman.core.objects.port_modes import BOND_MEMBER
from tests.adapters.compliance_test_case import ComplianceTestCase



class AddInterfaceToBondTest(ComplianceTestCase):
    _dev_sample = "juniper"

    def setUp(self):
        super(AddInterfaceToBondTest, self).setUp()
        self.client.add_bond(42)

    def tearDown(self):
        self.janitor.remove_bond(42)
        super(AddInterfaceToBondTest, self).tearDown()

    def test_sets_the_interface_bond_master(self):
        self.client.add_interface_to_bond(self.test_port, 42)
        interface = self.client.get_interface(self.test_port)

        assert_that(interface.bond_master, is_(42))

        self.janitor.remove_interface_from_bond(self.test_port)

    def test_sets_the_interface_port_mode_to_bond_members(self):
        self.client.add_interface_to_bond(self.test_port, 42)
        interface = self.client.get_interface(self.test_port)


        assert_that(interface.port_mode, is_(BOND_MEMBER))