forked from F5Networks/f5-common-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_requests_params.py
53 lines (48 loc) · 2.31 KB
/
test_requests_params.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright 2015-2016 F5 Networks Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from collections import namedtuple
PoolConfig = namedtuple('PoolConfig', 'partition name memberconfigs')
MemberConfig = namedtuple('MemberConfig', 'mempartition memname')
def test_get_collection(request, bigip, pool_factory, opt_release):
Pool1MemberConfigs = (MemberConfig('Common', '192.168.15.15:80'),
MemberConfig('Common', '192.168.16.16:8080'),)
Pool1Config = PoolConfig('Common', 'TEST', Pool1MemberConfigs)
test_pools = (Pool1Config,)
pool_registry, member_registry =\
pool_factory(bigip, request, test_pools)
selfLinks = []
for pool_inst in pool_registry.values():
for mem in pool_inst.members_s.get_collection():
selfLinks.append(mem.selfLink)
assert selfLinks[0] == u'https://localhost/mgmt/tm/ltm/pool/' +\
'~Common~TEST/members/~Common~192.168.15.15:80' +\
'?ver='+opt_release
assert selfLinks[1] == u'https://localhost/mgmt/tm/ltm/pool/' +\
'~Common~TEST/members/~Common~192.168.16.16:8080' +\
'?ver='+opt_release
def test_get_dollar_filtered_collection(request, bigip, pool_factory):
if bigip.sys.folders.folder.exists(name='za', partition=''):
bigip.sys.folders.folder.load(name='za', partition='')
else:
bigip.sys.folders.folder.create(name='za', subPath='/')
Pool1Config = PoolConfig('Common', 'TEST', ((),))
Pool2Config = PoolConfig('za', 'TEST', ((),))
test_pools = (Pool1Config, Pool2Config)
pool_registry, member_registry =\
pool_factory(bigip, request, test_pools)
rp = {'params': {'$filter': 'partition eq za'}}
pools_in_za = bigip.ltm.pools.get_collection(requests_params=rp)
muri = pools_in_za[0]._meta_data['uri']
assert muri.endswith('/mgmt/tm/ltm/pool/~za~TEST/')