def test_identifying_first_mapping_id(self): """Make sure first available ID is obtained for each ID type.""" # Simulate mapping table is empty - get first one self.query_mock.return_value = [] next_id = csr_db.get_next_available_tunnel_id(self.session) self.assertEqual(0, next_id) next_id = csr_db.get_next_available_ike_policy_id(self.session) self.assertEqual(1, next_id) next_id = csr_db.get_next_available_ipsec_policy_id(self.session) self.assertEqual(1, next_id)
def test_last_mapping_id_available(self): """Make sure can get the last ID for each of the table types.""" # Simulate query indicates table is full self.query_mock.return_value = [ (x, ) for x in xrange(csr_db.MAX_CSR_TUNNELS - 1)] next_id = csr_db.get_next_available_tunnel_id(self.session) self.assertEqual(csr_db.MAX_CSR_TUNNELS - 1, next_id) self.query_mock.return_value = [ (x, ) for x in xrange(1, csr_db.MAX_CSR_IKE_POLICIES)] next_id = csr_db.get_next_available_ike_policy_id(self.session) self.assertEqual(csr_db.MAX_CSR_IKE_POLICIES, next_id) self.query_mock.return_value = [ (x, ) for x in xrange(1, csr_db.MAX_CSR_IPSEC_POLICIES)] next_id = csr_db.get_next_available_ipsec_policy_id(self.session) self.assertEqual(csr_db.MAX_CSR_IPSEC_POLICIES, next_id)