Beispiel #1
0
 def test_TagsRequest_options(self):
     tid = '1234567890'
     dnStr = 'system'
     tr = TagsRequest(dnStr, add=u'tag1', remove=u'tag2')
     expectedOptions1 = 'add=tag1&remove=tag2'
     expectedOptions2 = 'remove=tag2&add=tag1'
     tr.id = tid
     expectedOptions1 += '&_dc=' + tid
     expectedOptions2 += '&_dc=' + tid
     assert (tr.options == expectedOptions1 or
             tr.options == expectedOptions2)
Beispiel #2
0
 def test_TagsRequest_options(self):
     tid = '1234567890'
     dnStr = 'system'
     tr = TagsRequest(dnStr, add=u'tag1', remove=u'tag2')
     expectedOptions1 = 'add=tag1&remove=tag2'
     expectedOptions2 = 'remove=tag2&add=tag1'
     tr.id = tid
     expectedOptions1 += '&_dc=' + tid
     expectedOptions2 += '&_dc=' + tid
     assert (tr.options == expectedOptions1 or
             tr.options == expectedOptions2)
Beispiel #3
0
 def test_TagsRequest_requestargs(self):
     expected = {
                    'data': '{}',
                    'headers': {
                        'Cookie': 'APIC-cookie=None'
                    },
                    'timeout': 90,
                    'verify': False
                }
     session = LoginSession('http://1.1.1.1', 'admin', 'password')
     dnStr = 'uni'
     tr = TagsRequest(dnStr)
     assert tr.requestargs(session) == expected
Beispiel #4
0
 def test_TagsRequest_getUrl(self, sessionUrl, dc, requestType):
     dnStr = 'uni'
     session = LoginSession(sessionUrl, 'admin', 'password',
                            requestFormat=requestType)
     tr = TagsRequest(dnStr)
     expectedUrl = sessionUrl + '/api/tag/mo/' + dnStr + '.' + requestType
     tr.add = [u'tag1', u'tag2']
     tr.remove = u'tag3'
     tr.id = dc
     expectedUrl1 = expectedUrl + '?add=tag1,tag2&remove=tag3&_dc=' + dc
     expectedUrl2 = expectedUrl + '?remove=tag3&add=tag1,tag2&_dc=' + dc
     assert (tr.getUrl(session) == expectedUrl1 or
             tr.getUrl(session) == expectedUrl2)
Beispiel #5
0
 def test_TagsRequest_requestargs(self):
     expected = {
                    'data': '{}',
                    'headers': {
                        'Cookie': 'APIC-cookie=None'
                    },
                    'timeout': 90,
                    'verify': False
                }
     session = LoginSession('http://1.1.1.1', 'admin', 'password')
     dnStr = 'uni'
     tr = TagsRequest(dnStr)
     assert tr.requestargs(session) == expected
Beispiel #6
0
 def test_TagsRequest_getUrl(self, sessionUrl, dc, requestType):
     dnStr = 'uni'
     session = LoginSession(sessionUrl,
                            'admin',
                            'password',
                            requestFormat=requestType)
     tr = TagsRequest(dnStr)
     expectedUrl = sessionUrl + '/api/tag/mo/' + dnStr + '.' + requestType
     tr.add = [u'tag1', u'tag2']
     tr.remove = u'tag3'
     tr.id = dc
     expectedUrl1 = expectedUrl + '?add=tag1,tag2&remove=tag3&_dc=' + dc
     expectedUrl2 = expectedUrl + '?remove=tag3&add=tag1,tag2&_dc=' + dc
     assert (tr.getUrl(session) == expectedUrl1
             or tr.getUrl(session) == expectedUrl2)
Beispiel #7
0
 def test_TagsRequest_add_remove_failed(self, addOrRemove, dnStr, value,
                                        errorType):
     tr = TagsRequest(dnStr)
     with pytest.raises(errorType):
         setattr(tr, addOrRemove, value)
Beispiel #8
0
 def test_TagsRequest_add_remove(self, addOrRemove, dnStr, value, expected):
     tr = TagsRequest(dnStr)
     setattr(tr, addOrRemove, value)
     assert getattr(tr, addOrRemove) == expected
Beispiel #9
0
 def test_TagsRequest_dnStr(self):
     dnStr = 'system'
     tr = TagsRequest(dnStr)
     assert tr.dnStr == dnStr
Beispiel #10
0
 def test_TagsRequest_data(self):
     tr = TagsRequest('uni')
     assert tr.data == '{}'
Beispiel #11
0
 def test_TagsRequest_init(self):
     assert isinstance(TagsRequest('fvTenant'), TagsRequest)