def test_hash(self): ports = { VNXHbaPort.create(VNXSPEnum.SP_A, 1), VNXHbaPort.create(VNXSPEnum.SP_B, 1), VNXHbaPort.create(VNXSPEnum.SP_A, 1) } assert_that(len(ports), equal_to(2))
def test_hash(self): ports = { VNXHbaPort.create(VNXSPEnum.SP_A, 1), VNXHbaPort.create(VNXSPEnum.SP_B, 1), VNXHbaPort.create(VNXSPEnum.SP_A, 1) } self.assertEqual(2, len(ports))
def hba_port_set(self): return { VNXHbaPort.create(VNXSPEnum.SP_A, 1), VNXHbaPort.create(VNXSPEnum.SP_B, 1), VNXHbaPort.create(VNXSPEnum.SP_A, 4), VNXHbaPort.create(VNXSPEnum.SP_A, 3, vport_id=1), VNXHbaPort.create(VNXSPEnum.SP_A, 6, vport_id=0), VNXHbaPort.create(VNXSPEnum.SP_B, 4, vport_id=0), }
def test_hba_equal_hba_port(self): hba = test_hba() h_port = VNXHbaPort.create('a', 3, vport_id=1) assert_that(hba, equal_to(h_port))
def test_as_tuple(self): port = VNXHbaPort.create(VNXSPEnum.SP_A, 1) assert_that(port.as_tuple(), only_contains(VNXSPEnum.SP_A, 1))
def test_get_sp_index(self): port = VNXHbaPort.create('spb', '5') assert_that(port.get_sp_index(), equal_to('b')) assert_that(port.port_id, equal_to(5))
def f(): port = VNXHbaPort.create('A', 'a1') assert_that(port.is_valid(), equal_to(False)) assert_that(port.port_id, none())
def test_set_sp(self): port = VNXHbaPort.create('A', 3) assert_that(port.sp, equal_to(VNXSPEnum.SP_A))
def test_set_sp_error(self): port = VNXHbaPort.create('Z', 3) self.assertEqual(False, port.is_valid()) self.assertIsNone(port.sp)
def test_repr(self): port = VNXHbaPort.create(VNXSPEnum.SP_B, 3) ret = port.__repr__() assert_that(ret, contains_string('"sp": "VNXSPEnum.SP_B"')) assert_that(ret, contains_string('"existed": true'))
def test_equal(self): spa_1 = VNXHbaPort.create(VNXSPEnum.SP_A, 1) spa_1_dup = VNXHbaPort.create(VNXSPEnum.SP_A, 1) spa_2 = VNXHbaPort.create(VNXSPEnum.SP_A, 2) assert_that(spa_1_dup, equal_to(spa_1)) assert_that(spa_1, is_not(equal_to(spa_2)))
def test_create_tuple_input(self): inputs = ('a', 5) port = VNXHbaPort.create(*inputs) assert_that(port.sp, equal_to(VNXSPEnum.SP_A)) assert_that(port.port_id, equal_to(5))
def test_set_sp(self): port = VNXHbaPort.create('A', 3) self.assertEqual(VNXSPEnum.SP_A, port.sp)
def test_connection_port_equal_hba_port(self): c_port = VNXConnectionPort(sp='a', port_id=4, cli=t_cli()) h_port = VNXHbaPort.create('a', 4, vport_id=0) assert_that(c_port, equal_to(h_port))
def f(): port = VNXHbaPort.create('A', 'a1') self.assertEqual(False, port.is_valid()) self.assertIsNone(port.port_id)
def test_set_sp_error(self): port = VNXHbaPort.create('Z', 3) assert_that(port.is_valid(), equal_to(False)) assert_that(port.sp, none())
def test_create_tuple_input(self): inputs = ('a', 5) port = VNXHbaPort.create(*inputs) self.assertEqual(VNXSPEnum.SP_A, port.sp) self.assertEqual(5, port.port_id)
def test_get_sp_index(self): port = VNXHbaPort.create('spb', '5') self.assertEqual('b', port.get_sp_index()) self.assertEqual(5, port.port_id)
def test_equal(self): spa_1 = VNXHbaPort.create(VNXSPEnum.SP_A, 1) spa_1_dup = VNXHbaPort.create(VNXSPEnum.SP_A, 1) spa_2 = VNXHbaPort.create(VNXSPEnum.SP_A, 2) self.assertEqual(spa_1, spa_1_dup) self.assertEqual(False, spa_1 == spa_2)
def test_as_tuple(self): port = VNXHbaPort.create(VNXSPEnum.SP_A, 1) self.assertEqual(('SP A', 1), port.as_tuple())
def test_repr(self): port = VNXHbaPort.create(VNXSPEnum.SP_B, 3) self.assertEqual(port.__repr__(), '<VNXPort {sp: SP B, port_id: 3, ' 'vport_id: 0, host_initiator_list: ()}>')