How to use send_request method in avocado

Best Python code snippet using avocado_python

api.py

Source:api.py Github

copy

Full Screen

...17 18 self.GENERICFILTER={"sortBy": "" , "offset": "", "limit": ""} 1920 #==============================21 def send_request(self, data):22 23 try:24 time.sleep(self.delay)25 self.EXTRAINFO=''26 headers = {}27 data["token"]= self.token28 29 req = requests.post(self.APIURL, json.dumps(data).encode("utf-8"),headers=headers)30 31 logging.debug( req.status_code)32 logging.debug( req.reason)33 if (req.status_code != 200):34 logging.error( u'Too Many Requests' )35 return False , "Too Many Requests"36 37 j = json.loads(req.text)38 39 if ( "result" not in j):40 logging.debug( u'Wrong response data')41 return False, j["error"]42 else:43 self.EXTRAINFO = j["resultExtraInfo"]44 return True , j["result"]45 46 except Exception as e:47 logging.error( u'This is an exception. Message:' )48 logging.error( e )49 return False , ""50 51 52 #==============================53 def genericFilter(self, sortBy, offset, limit):54 self.GENERICFILTER = {55 "sortBy": sortBy,56 "offset": offset,57 "limit": limit58 }59 60 #====================61 62 def genericFilterClear(self):63 self.GENERICFILTER = { "sortBy": "","offset": "", "limit": "" }6465 #====================66 67 def getExtraInfo(self):68 return self.EXTRAINFO69 #==================== 70 def getSystemInfo(self): 71 data={"jsonrpc": "2.0",72 "method":"getSystemInfo",73 "params": {74 },75 "filter": self.GENERICFILTER76 }77 logging.info( u'getSystemInfo method call' )78 return self.send_request(data)79 #==================== 80 def getProfileStatus(self): 81 data={"jsonrpc": "2.0",82 "method":"getProfileStatus",83 "params": {84 },85 "filter": self.GENERICFILTER86 }87 logging.info( u'getProfileStatus method call' )88 return self.send_request(data)89 #==================== 90 def setProfileStatus(self, status, mood): 91 data={"jsonrpc": "2.0",92 "method":"setProfileStatus",93 "params": {94 'status' : status,95 'mood' : mood },96 "filter": self.GENERICFILTER97 }98 logging.info( u'setProfileStatus method call' )99 return self.send_request(data)100 #==================== 101 def getReleaseNotes(self): 102 data={"jsonrpc": "2.0",103 "method":"getReleaseNotes",104 "params": {105 },106 "filter": self.GENERICFILTER107 }108 logging.info( u'getReleaseNotes method call' )109 return self.send_request(data)110 #==================== 111 def getSettingInfo(self, settingId): 112 data={"jsonrpc": "2.0",113 "method":"getSettingInfo",114 "params": {115 'settingId' : settingId },116 "filter": self.GENERICFILTER117 }118 logging.info( u'getSettingInfo method call' )119 return self.send_request(data)120 #==================== 121 def setSettingInfo(self, settingId, newValue): 122 data={"jsonrpc": "2.0",123 "method":"setSettingInfo",124 "params": {125 'settingId' : settingId,126 'newValue' : newValue },127 "filter": self.GENERICFILTER128 }129 logging.info( u'setSettingInfo method call' )130 return self.send_request(data)131 #==================== 132 def getOwnContact(self): 133 data={"jsonrpc": "2.0",134 "method":"getOwnContact",135 "params": {136 },137 "filter": self.GENERICFILTER138 }139 logging.info( u'getOwnContact method call' )140 return self.send_request(data)141 #==================== 142 def getContacts(self, filter): 143 data={"jsonrpc": "2.0",144 "method":"getContacts",145 "params": {146 'filter' : filter },147 "filter": self.GENERICFILTER148 }149 logging.info( u'getContacts method call' )150 return self.send_request(data)151 #==================== 152 def getContactAvatar(self, pk, coder, format): 153 data={"jsonrpc": "2.0",154 "method":"getContactAvatar",155 "params": {156 'pk' : pk,157 'coder' : coder,158 'format' : format },159 "filter": self.GENERICFILTER160 }161 logging.info( u'getContactAvatar method call' )162 return self.send_request(data)163 #==================== 164 def getChannelAvatar(self, channelid, coder, format): 165 data={"jsonrpc": "2.0",166 "method":"getChannelAvatar",167 "params": {168 'channelid' : channelid,169 'coder' : coder,170 'format' : format },171 "filter": self.GENERICFILTER172 }173 logging.info( u'getChannelAvatar method call' )174 return self.send_request(data)175 #==================== 176 def setContactGroup(self, contactPublicKey, groupName): 177 data={"jsonrpc": "2.0",178 "method":"setContactGroup",179 "params": {180 'contactPublicKey' : contactPublicKey,181 'groupName' : groupName },182 "filter": self.GENERICFILTER183 }184 logging.info( u'setContactGroup method call' )185 return self.send_request(data)186 #==================== 187 def setContactNick(self, contactPublicKey, newNick): 188 data={"jsonrpc": "2.0",189 "method":"setContactNick",190 "params": {191 'contactPublicKey' : contactPublicKey,192 'newNick' : newNick },193 "filter": self.GENERICFILTER194 }195 logging.info( u'setContactNick method call' )196 return self.send_request(data)197 #==================== 198 def sendInstantMessage(self, tohex, text): 199 data={"jsonrpc": "2.0",200 "method":"sendInstantMessage",201 "params": {202 'to' : tohex,203 'text' : text },204 "filter": self.GENERICFILTER205 }206 logging.info( u'sendInstantMessage method call' )207 return self.send_request(data)208 #==================== 209 def sendInstantQuote(self, tohex, text, id_message): 210 data={"jsonrpc": "2.0",211 "method":"sendInstantQuote",212 "params": {213 'to' : tohex,214 'text' : text,215 'id_message' : id_message },216 "filter": self.GENERICFILTER217 }218 logging.info( u'sendInstantQuote method call' )219 return self.send_request(data)220 #==================== 221 def pinInstantMessage(self, tohex, messageId, pin): 222 data={"jsonrpc": "2.0",223 "method":"pinInstantMessage",224 "params": {225 'to' : tohex,226 'messageId' : messageId,227 'pin' : pin },228 "filter": self.GENERICFILTER229 }230 logging.info( u'pinInstantMessage method call' )231 return self.send_request(data)232 #==================== 233 def bookmarkInstantMessage(self, messageId, comments): 234 data={"jsonrpc": "2.0",235 "method":"bookmarkInstantMessage",236 "params": {237 'messageId' : messageId,238 'comments' : comments },239 "filter": self.GENERICFILTER240 }241 logging.info( u'bookmarkInstantMessage method call' )242 return self.send_request(data)243 #==================== 244 def getPinnedMessages(self, pk): 245 data={"jsonrpc": "2.0",246 "method":"getPinnedMessages",247 "params": {248 'pk' : pk },249 "filter": self.GENERICFILTER250 }251 logging.info( u'getPinnedMessages method call' )252 return self.send_request(data)253 #==================== 254 def getStickerCollections(self): 255 data={"jsonrpc": "2.0",256 "method":"getStickerCollections",257 "params": {258 },259 "filter": self.GENERICFILTER260 }261 logging.info( u'getStickerCollections method call' )262 return self.send_request(data)263 #==================== 264 def getStickerNamesByCollection(self, collection_name): 265 data={"jsonrpc": "2.0",266 "method":"getStickerNamesByCollection",267 "params": {268 'collection_name' : collection_name },269 "filter": self.GENERICFILTER270 }271 logging.info( u'getStickerNamesByCollection method call' )272 return self.send_request(data)273 #==================== 274 def getImageSticker(self, collection_name, sticker_name, coder): 275 data={"jsonrpc": "2.0",276 "method":"getImageSticker",277 "params": {278 'collection_name' : collection_name,279 'sticker_name' : sticker_name,280 'coder' : coder },281 "filter": self.GENERICFILTER282 }283 logging.info( u'getImageSticker method call' )284 return self.send_request(data)285 #==================== 286 def sendInstantSticker(self, tohex, collection, name): 287 data={"jsonrpc": "2.0",288 "method":"sendInstantSticker",289 "params": {290 'to' : tohex,291 'collection' : collection,292 'name' : name },293 "filter": self.GENERICFILTER294 }295 logging.info( u'sendInstantSticker method call' )296 return self.send_request(data)297 #==================== 298 def sendInstantBuzz(self, tohex, comments): 299 data={"jsonrpc": "2.0",300 "method":"sendInstantBuzz",301 "params": {302 'to' : tohex,303 'comments' : comments },304 "filter": self.GENERICFILTER305 }306 logging.info( u'sendInstantBuzz method call' )307 return self.send_request(data)308 #==================== 309 def sendInstantInvitation(self, tohex, channelid, description, comments): 310 data={"jsonrpc": "2.0",311 "method":"sendInstantInvitation",312 "params": {313 'to' : tohex,314 'channelid' : channelid,315 'description' : description,316 'comments' : comments },317 "filter": self.GENERICFILTER318 }319 logging.info( u'sendInstantInvitation method call' )320 return self.send_request(data)321 #==================== 322 def removeInstantMessages(self, hex_contact_public_key): 323 data={"jsonrpc": "2.0",324 "method":"removeInstantMessages",325 "params": {326 'hex_contact_public_key' : hex_contact_public_key },327 "filter": self.GENERICFILTER328 }329 logging.info( u'removeInstantMessages method call' )330 return self.send_request(data)331 #==================== 332 def getContactMessages(self, pk): 333 data={"jsonrpc": "2.0",334 "method":"getContactMessages",335 "params": {336 'pk' : pk },337 "filter": self.GENERICFILTER338 }339 logging.info( u'getContactMessages method call' )340 return self.send_request(data)341 #==================== 342 def sendEmailMessage(self, tohex, subject, body, attachmentFileId): 343 data={"jsonrpc": "2.0",344 "method":"sendEmailMessage",345 "params": {346 'to' : tohex,347 'subject' : subject,348 'body' : body,349 'attachmentFileId' : attachmentFileId },350 "filter": self.GENERICFILTER351 }352 logging.info( u'sendEmailMessage method call' )353 return self.send_request(data)354 #==================== 355 def sendPayment(self, tohex, comment, cardid, amount): 356 data={"jsonrpc": "2.0",357 "method":"sendPayment",358 "params": {359 'to' : tohex,360 'comment' : comment,361 'cardid' : cardid,362 'amount' : amount },363 "filter": self.GENERICFILTER364 }365 logging.info( u'sendPayment method call' )366 return self.send_request(data)367 #==================== 368 def getEmailFolder(self, folderType, filter): 369 data={"jsonrpc": "2.0",370 "method":"getEmailFolder",371 "params": {372 'folderType' : folderType,373 'filter' : filter },374 "filter": self.GENERICFILTER375 }376 logging.info( u'getEmailFolder method call' )377 return self.send_request(data)378 #==================== 379 def getEmails(self, folderType, filter): 380 data={"jsonrpc": "2.0",381 "method":"getEmails",382 "params": {383 'folderType' : folderType,384 'filter' : filter },385 "filter": self.GENERICFILTER386 }387 logging.info( u'getEmails method call' )388 return self.send_request(data)389 #==================== 390 def abortAttachment(self, emailId, fileId): 391 data={"jsonrpc": "2.0",392 "method":"abortAttachment",393 "params": {394 'emailId' : emailId,395 'fileId' : fileId },396 "filter": self.GENERICFILTER397 }398 logging.info( u'abortAttachment method call' )399 return self.send_request(data)400 #==================== 401 def acceptAttachment(self, emailId, fileId): 402 data={"jsonrpc": "2.0",403 "method":"acceptAttachment",404 "params": {405 'emailId' : emailId,406 'fileId' : fileId },407 "filter": self.GENERICFILTER408 }409 logging.info( u'acceptAttachment method call' )410 return self.send_request(data)411 #==================== 412 def acceptFileMessage(self, messageId): 413 data={"jsonrpc": "2.0",414 "method":"acceptFileMessage",415 "params": {416 'messageId' : messageId },417 "filter": self.GENERICFILTER418 }419 logging.info( u'acceptFileMessage method call' )420 return self.send_request(data)421 #==================== 422 def abortFileMessage(self, messageId): 423 data={"jsonrpc": "2.0",424 "method":"abortFileMessage",425 "params": {426 'messageId' : messageId },427 "filter": self.GENERICFILTER428 }429 logging.info( u'abortFileMessage method call' )430 return self.send_request(data)431 #==================== 432 def getEmailById(self, id): 433 data={"jsonrpc": "2.0",434 "method":"getEmailById",435 "params": {436 'id' : id },437 "filter": self.GENERICFILTER438 }439 logging.info( u'getEmailById method call' )440 return self.send_request(data)441 #==================== 442 def deleteEmail(self, id): 443 data={"jsonrpc": "2.0",444 "method":"deleteEmail",445 "params": {446 'id' : id },447 "filter": self.GENERICFILTER448 }449 logging.info( u'deleteEmail method call' )450 return self.send_request(data)451 #==================== 452 def sendReplyEmailMessage(self, id, body, subject, attachmentFileId): 453 data={"jsonrpc": "2.0",454 "method":"sendReplyEmailMessage",455 "params": {456 'id' : id,457 'body' : body,458 'subject' : subject,459 'attachmentFileId' : attachmentFileId },460 "filter": self.GENERICFILTER461 }462 logging.info( u'sendReplyEmailMessage method call' )463 return self.send_request(data)464 #==================== 465 def sendForwardEmailMessage(self, id, tohex, body, subject, attachmentFileId): 466 data={"jsonrpc": "2.0",467 "method":"sendForwardEmailMessage",468 "params": {469 'id' : id,470 'to' : tohex,471 'body' : body,472 'subject' : subject,473 'attachmentFileId' : attachmentFileId },474 "filter": self.GENERICFILTER475 }476 logging.info( u'sendForwardEmailMessage method call' )477 return self.send_request(data)478 #==================== 479 def sendEmailInvitation(self, channelid, tohex, description, comments): 480 data={"jsonrpc": "2.0",481 "method":"sendEmailInvitation",482 "params": {483 'channelid' : channelid,484 'to' : tohex,485 'description' : description,486 'comments' : comments },487 "filter": self.GENERICFILTER488 }489 logging.info( u'sendEmailInvitation method call' )490 return self.send_request(data)491 #==================== 492 def emptyEmailsTrash(self): 493 data={"jsonrpc": "2.0",494 "method":"emptyEmailsTrash",495 "params": {496 },497 "filter": self.GENERICFILTER498 }499 logging.info( u'emptyEmailsTrash method call' )500 return self.send_request(data)501 #==================== 502 def getFinanceSystemInformation(self): 503 data={"jsonrpc": "2.0",504 "method":"getFinanceSystemInformation",505 "params": {506 },507 "filter": self.GENERICFILTER508 }509 logging.info( u'getFinanceSystemInformation method call' )510 return self.send_request(data)511 #==================== 512 def getBalance(self): 513 data={"jsonrpc": "2.0",514 "method":"getBalance",515 "params": {516 },517 "filter": self.GENERICFILTER518 }519 logging.info( u'getBalance method call' )520 return self.send_request(data)521 #==================== 522 def getFinanceHistory(self, filters, referenceNumber, fromDate, toDate, batchId, fromAmount, toAmount): 523 data={"jsonrpc": "2.0",524 "method":"getFinanceHistory",525 "params": {526 'filters' : filters,527 'referenceNumber' : referenceNumber,528 'fromDate' : fromDate,529 'toDate' : toDate,530 'batchId' : batchId,531 'fromAmount' : fromAmount,532 'toAmount' : toAmount },533 "filter": self.GENERICFILTER534 }535 logging.info( u'getFinanceHistory method call' )536 return self.send_request(data)537 #==================== 538 def getCards(self): 539 data={"jsonrpc": "2.0",540 "method":"getCards",541 "params": {542 },543 "filter": self.GENERICFILTER544 }545 logging.info( u'getCards method call' )546 return self.send_request(data)547 #==================== 548 def addCard(self, color, name, preorderNumberInCard): 549 data={"jsonrpc": "2.0",550 "method":"addCard",551 "params": {552 'color' : color,553 'name' : name,554 'preorderNumberInCard' : preorderNumberInCard },555 "filter": self.GENERICFILTER556 }557 logging.info( u'addCard method call' )558 return self.send_request(data)559 #==================== 560 def deleteCard(self, cardId): 561 data={"jsonrpc": "2.0",562 "method":"deleteCard",563 "params": {564 'cardId' : cardId },565 "filter": self.GENERICFILTER566 }567 logging.info( u'deleteCard method call' )568 return self.send_request(data)569 #==================== 570 def enableMining(self, enable): 571 data={"jsonrpc": "2.0",572 "method":"enableMining",573 "params": {574 'enable' : enable },575 "filter": self.GENERICFILTER576 }577 logging.info( u'enableMining method call' )578 return self.send_request(data)579 #==================== 580 def enablePoS(self, enable): 581 data={"jsonrpc": "2.0",582 "method":"enablePoS",583 "params": {584 'enable' : enable },585 "filter": self.GENERICFILTER586 }587 logging.info( u'enablePoS method call' )588 return self.send_request(data)589 #==================== 590 def enableHistoryMining(self, enable): 591 data={"jsonrpc": "2.0",592 "method":"enableHistoryMining",593 "params": {594 'enable' : enable },595 "filter": self.GENERICFILTER596 }597 logging.info( u'enableHistoryMining method call' )598 return self.send_request(data)599 #==================== 600 def statusHistoryMining(self): 601 data={"jsonrpc": "2.0",602 "method":"statusHistoryMining",603 "params": {604 },605 "filter": self.GENERICFILTER606 }607 logging.info( u'statusHistoryMining method call' )608 return self.send_request(data)609 #==================== 610 def getMiningBlocks(self): 611 data={"jsonrpc": "2.0",612 "method":"getMiningBlocks",613 "params": {614 },615 "filter": self.GENERICFILTER616 }617 logging.info( u'getMiningBlocks method call' )618 return self.send_request(data)619 #==================== 620 def getMiningInfo(self): 621 data={"jsonrpc": "2.0",622 "method":"getMiningInfo",623 "params": {624 },625 "filter": self.GENERICFILTER626 }627 logging.info( u'getMiningInfo method call' )628 return self.send_request(data)629 #==================== 630 def getVouchers(self): 631 data={"jsonrpc": "2.0",632 "method":"getVouchers",633 "params": {634 },635 "filter": self.GENERICFILTER636 }637 logging.info( u'getVouchers method call' )638 return self.send_request(data)639 #==================== 640 def createVoucher(self, amount): 641 data={"jsonrpc": "2.0",642 "method":"createVoucher",643 "params": {644 'amount' : amount },645 "filter": self.GENERICFILTER646 }647 logging.info( u'createVoucher method call' )648 return self.send_request(data)649 #==================== 650 def useVoucher(self, voucherid): 651 data={"jsonrpc": "2.0",652 "method":"useVoucher",653 "params": {654 'voucherid' : voucherid },655 "filter": self.GENERICFILTER656 }657 logging.info( u'useVoucher method call' )658 return self.send_request(data)659 #==================== 660 def deleteVoucher(self, voucherid): 661 data={"jsonrpc": "2.0",662 "method":"deleteVoucher",663 "params": {664 'voucherid' : voucherid },665 "filter": self.GENERICFILTER666 }667 logging.info( u'deleteVoucher method call' )668 return self.send_request(data)669 #==================== 670 def getInvoices(self, parameters): 671 data={"jsonrpc": "2.0",672 "method":"getInvoices",673 "params": {674 'parameters' : parameters },675 "filter": self.GENERICFILTER676 }677 logging.info( u'getInvoices method call' )678 return self.send_request(data)679 #==================== 680 def getInvoiceByReferenceNumber(self, referenceNumber): 681 data={"jsonrpc": "2.0",682 "method":"getInvoiceByReferenceNumber",683 "params": {684 'referenceNumber' : referenceNumber },685 "filter": self.GENERICFILTER686 }687 logging.info( u'getInvoiceByReferenceNumber method call' )688 return self.send_request(data)689 #==================== 690 def getTransactionIdByReferenceNumber(self, referenceNumber): 691 data={"jsonrpc": "2.0",692 "method":"getTransactionIdByReferenceNumber",693 "params": {694 'referenceNumber' : referenceNumber },695 "filter": self.GENERICFILTER696 }697 logging.info( u'getTransactionIdByReferenceNumber method call' )698 return self.send_request(data)699 #==================== 700 def sendInvoice(self, comment, cardid, amount): 701 data={"jsonrpc": "2.0",702 "method":"sendInvoice",703 "params": {704 'comment' : comment,705 'cardid' : cardid,706 'amount' : amount },707 "filter": self.GENERICFILTER708 }709 logging.info( u'sendInvoice method call' )710 return self.send_request(data)711 #==================== 712 def acceptInvoice(self, invoiceid): 713 data={"jsonrpc": "2.0",714 "method":"acceptInvoice",715 "params": {716 'invoiceid' : invoiceid },717 "filter": self.GENERICFILTER718 }719 logging.info( u'acceptInvoice method call' )720 return self.send_request(data)721 #==================== 722 def declineInvoice(self, invoiceid): 723 data={"jsonrpc": "2.0",724 "method":"declineInvoice",725 "params": {726 'invoiceid' : invoiceid },727 "filter": self.GENERICFILTER728 }729 logging.info( u'declineInvoice method call' )730 return self.send_request(data)731 #==================== 732 def cancelInvoice(self, invoiceid): 733 data={"jsonrpc": "2.0",734 "method":"cancelInvoice",735 "params": {736 'invoiceid' : invoiceid },737 "filter": self.GENERICFILTER738 }739 logging.info( u'cancelInvoice method call' )740 return self.send_request(data)741 #==================== 742 def requestUnsTransfer(self, name, hexNewOwnerPk): 743 data={"jsonrpc": "2.0",744 "method":"requestUnsTransfer",745 "params": {746 'name' : name,747 'hexNewOwnerPk' : hexNewOwnerPk },748 "filter": self.GENERICFILTER749 }750 logging.info( u'requestUnsTransfer method call' )751 return self.send_request(data)752 #==================== 753 def acceptUnsTransfer(self, requestId): 754 data={"jsonrpc": "2.0",755 "method":"acceptUnsTransfer",756 "params": {757 'requestId' : requestId },758 "filter": self.GENERICFILTER759 }760 logging.info( u'acceptUnsTransfer method call' )761 return self.send_request(data)762 #==================== 763 def declineUnsTransfer(self, requestId): 764 data={"jsonrpc": "2.0",765 "method":"declineUnsTransfer",766 "params": {767 'requestId' : requestId },768 "filter": self.GENERICFILTER769 }770 logging.info( u'declineUnsTransfer method call' )771 return self.send_request(data)772 #==================== 773 def incomingUnsTransfer(self): 774 data={"jsonrpc": "2.0",775 "method":"incomingUnsTransfer",776 "params": {777 },778 "filter": self.GENERICFILTER779 }780 logging.info( u'incomingUnsTransfer method call' )781 return self.send_request(data)782 #==================== 783 def outgoingUnsTransfer(self): 784 data={"jsonrpc": "2.0",785 "method":"outgoingUnsTransfer",786 "params": {787 },788 "filter": self.GENERICFILTER789 }790 logging.info( u'outgoingUnsTransfer method call' )791 return self.send_request(data)792 #==================== 793 def storageWipe(self): 794 data={"jsonrpc": "2.0",795 "method":"storageWipe",796 "params": {797 },798 "filter": self.GENERICFILTER799 }800 logging.info( u'storageWipe method call' )801 return self.send_request(data)802 #==================== 803 def sendAuthorizationRequest(self, pk, message): 804 data={"jsonrpc": "2.0",805 "method":"sendAuthorizationRequest",806 "params": {807 'pk' : pk,808 'message' : message },809 "filter": self.GENERICFILTER810 }811 logging.info( u'sendAuthorizationRequest method call' )812 return self.send_request(data)813 #==================== 814 def acceptAuthorizationRequest(self, pk, message): 815 data={"jsonrpc": "2.0",816 "method":"acceptAuthorizationRequest",817 "params": {818 'pk' : pk,819 'message' : message },820 "filter": self.GENERICFILTER821 }822 logging.info( u'acceptAuthorizationRequest method call' )823 return self.send_request(data)824 #==================== 825 def rejectAuthorizationRequest(self, pk, message): 826 data={"jsonrpc": "2.0",827 "method":"rejectAuthorizationRequest",828 "params": {829 'pk' : pk,830 'message' : message },831 "filter": self.GENERICFILTER832 }833 logging.info( u'rejectAuthorizationRequest method call' )834 return self.send_request(data)835 #==================== 836 def deleteContact(self, pk): 837 data={"jsonrpc": "2.0",838 "method":"deleteContact",839 "params": {840 'pk' : pk },841 "filter": self.GENERICFILTER842 }843 logging.info( u'deleteContact method call' )844 return self.send_request(data)845 #==================== 846 def getChannels(self, filter, channel_type): 847 data={"jsonrpc": "2.0",848 "method":"getChannels",849 "params": {850 'filter' : filter,851 'channel_type' : channel_type },852 "filter": self.GENERICFILTER853 }854 logging.info( u'getChannels method call' )855 return self.send_request(data)856 #==================== 857 def sendChannelMessage(self, channelid, message): 858 data={"jsonrpc": "2.0",859 "method":"sendChannelMessage",860 "params": {861 'channelid' : channelid,862 'message' : message },863 "filter": self.GENERICFILTER864 }865 logging.info( u'sendChannelMessage method call' )866 return self.send_request(data)867 #==================== 868 def sendChannelPicture(self, channelid, base64_image, filename_image): 869 data={"jsonrpc": "2.0",870 "method":"sendChannelPicture",871 "params": {872 'channelid' : channelid,873 'base64_image' : base64_image,874 'filename_image' : filename_image },875 "filter": self.GENERICFILTER876 }877 logging.info( u'sendChannelPicture method call' )878 return self.send_request(data)879 #==================== 880 def joinChannel(self, ident, password): 881 data={"jsonrpc": "2.0",882 "method":"joinChannel",883 "params": {884 'ident' : ident,885 'password' : password },886 "filter": self.GENERICFILTER887 }888 logging.info( u'joinChannel method call' )889 return self.send_request(data)890 #==================== 891 def leaveChannel(self, channelid): 892 data={"jsonrpc": "2.0",893 "method":"leaveChannel",894 "params": {895 'channelid' : channelid },896 "filter": self.GENERICFILTER897 }898 logging.info( u'leaveChannel method call' )899 return self.send_request(data)900 #==================== 901 def setChannelAsBookmarked(self, channelid, bookmarked): 902 data={"jsonrpc": "2.0",903 "method":"setChannelAsBookmarked",904 "params": {905 'channelid' : channelid,906 'bookmarked' : bookmarked },907 "filter": self.GENERICFILTER908 }909 logging.info( u'setChannelAsBookmarked method call' )910 return self.send_request(data)911 #==================== 912 def getChannelContacts(self, channelid): 913 data={"jsonrpc": "2.0",914 "method":"getChannelContacts",915 "params": {916 'channelid' : channelid },917 "filter": self.GENERICFILTER918 }919 logging.info( u'getChannelContacts method call' )920 return self.send_request(data)921 #==================== 922 def getChannelMessages(self, channelid): 923 data={"jsonrpc": "2.0",924 "method":"getChannelMessages",925 "params": {926 'channelid' : channelid },927 "filter": self.GENERICFILTER928 }929 logging.info( u'getChannelMessages method call' )930 return self.send_request(data)931 #==================== 932 def getChannelInfo(self, channelid): 933 data={"jsonrpc": "2.0",934 "method":"getChannelInfo",935 "params": {936 'channelid' : channelid },937 "filter": self.GENERICFILTER938 }939 logging.info( u'getChannelInfo method call' )940 return self.send_request(data)941 #==================== 942 def getChannelModerators(self, channelid): 943 data={"jsonrpc": "2.0",944 "method":"getChannelModerators",945 "params": {946 'channelid' : channelid },947 "filter": self.GENERICFILTER948 }949 logging.info( u'getChannelModerators method call' )950 return self.send_request(data)951 #==================== 952 def getChannelModeratorRight(self, channelid, moderator): 953 data={"jsonrpc": "2.0",954 "method":"getChannelModeratorRight",955 "params": {956 'channelid' : channelid,957 'moderator' : moderator },958 "filter": self.GENERICFILTER959 }960 logging.info( u'getChannelModeratorRight method call' )961 return self.send_request(data)962 #==================== 963 def createChannel(self, channel_name, description, read_only, read_only_privacy, password, languages, hashtags, geoTag, base64_avatar_image, hide_in_UI): 964 data={"jsonrpc": "2.0",965 "method":"createChannel",966 "params": {967 'channel_name' : channel_name,968 'description' : description,969 'read_only' : read_only,970 'read_only_privacy' : read_only_privacy,971 'password' : password,972 'languages' : languages,973 'hashtags' : hashtags,974 'geoTag' : geoTag,975 'base64_avatar_image' : base64_avatar_image,976 'hide_in_UI' : hide_in_UI },977 "filter": self.GENERICFILTER978 }979 logging.info( u'createChannel method call' )980 return self.send_request(data)981 #==================== 982 def modifyChannel(self, channelid, description, read_only, read_only_privacy, password, languages, hashtags, geoTag, base64_avatar_image, hide_in_UI): 983 data={"jsonrpc": "2.0",984 "method":"modifyChannel",985 "params": {986 'channelid' : channelid,987 'description' : description,988 'read_only' : read_only,989 'read_only_privacy' : read_only_privacy,990 'password' : password,991 'languages' : languages,992 'hashtags' : hashtags,993 'geoTag' : geoTag,994 'base64_avatar_image' : base64_avatar_image,995 'hide_in_UI' : hide_in_UI },996 "filter": self.GENERICFILTER997 }998 logging.info( u'modifyChannel method call' )999 return self.send_request(data)1000 #==================== 1001 def modifyChannelTitle(self, channelid, newTitle, password): 1002 data={"jsonrpc": "2.0",1003 "method":"modifyChannelTitle",1004 "params": {1005 'channelid' : channelid,1006 'newTitle' : newTitle,1007 'password' : password },1008 "filter": self.GENERICFILTER1009 }1010 logging.info( u'modifyChannelTitle method call' )1011 return self.send_request(data)1012 #==================== 1013 def modifyChannelPassword(self, channelid, newPassword, password): 1014 data={"jsonrpc": "2.0",1015 "method":"modifyChannelPassword",1016 "params": {1017 'channelid' : channelid,1018 'newPassword' : newPassword,1019 'password' : password },1020 "filter": self.GENERICFILTER1021 }1022 logging.info( u'modifyChannelPassword method call' )1023 return self.send_request(data)1024 #==================== 1025 def deleteChannel(self, channelid, password): 1026 data={"jsonrpc": "2.0",1027 "method":"deleteChannel",1028 "params": {1029 'channelid' : channelid,1030 'password' : password },1031 "filter": self.GENERICFILTER1032 }1033 logging.info( u'deleteChannel method call' )1034 return self.send_request(data)1035 #==================== 1036 def getChannelSystemInfo(self): 1037 data={"jsonrpc": "2.0",1038 "method":"getChannelSystemInfo",1039 "params": {1040 },1041 "filter": self.GENERICFILTER1042 }1043 logging.info( u'getChannelSystemInfo method call' )1044 return self.send_request(data)1045 #==================== 1046 def unsCreateRecordRequest(self, nick, valid, isPrimary, channelId): 1047 data={"jsonrpc": "2.0",1048 "method":"unsCreateRecordRequest",1049 "params": {1050 'nick' : nick,1051 'valid' : valid,1052 'isPrimary' : isPrimary,1053 'channelId' : channelId },1054 "filter": self.GENERICFILTER1055 }1056 logging.info( u'unsCreateRecordRequest method call' )1057 return self.send_request(data)1058 #==================== 1059 def unsModifyRecordRequest(self, nick, valid, isPrimary, channelId): 1060 data={"jsonrpc": "2.0",1061 "method":"unsModifyRecordRequest",1062 "params": {1063 'nick' : nick,1064 'valid' : valid,1065 'isPrimary' : isPrimary,1066 'channelId' : channelId },1067 "filter": self.GENERICFILTER1068 }1069 logging.info( u'unsModifyRecordRequest method call' )1070 return self.send_request(data)1071 #==================== 1072 def unsDeleteRecordRequest(self, nick): 1073 data={"jsonrpc": "2.0",1074 "method":"unsDeleteRecordRequest",1075 "params": {1076 'nick' : nick },1077 "filter": self.GENERICFILTER1078 }1079 logging.info( u'unsDeleteRecordRequest method call' )1080 return self.send_request(data)1081 #==================== 1082 def unsSearchByPk(self, filter): 1083 data={"jsonrpc": "2.0",1084 "method":"unsSearchByPk",1085 "params": {1086 'filter' : filter },1087 "filter": self.GENERICFILTER1088 }1089 logging.info( u'unsSearchByPk method call' )1090 return self.send_request(data)1091 #==================== 1092 def unsSearchByNick(self, filter): 1093 data={"jsonrpc": "2.0",1094 "method":"unsSearchByNick",1095 "params": {1096 'filter' : filter },1097 "filter": self.GENERICFILTER1098 }1099 logging.info( u'unsSearchByNick method call' )1100 return self.send_request(data)1101 #==================== 1102 def getUnsSyncInfo(self): 1103 data={"jsonrpc": "2.0",1104 "method":"getUnsSyncInfo",1105 "params": {1106 },1107 "filter": self.GENERICFILTER1108 }1109 logging.info( u'getUnsSyncInfo method call' )1110 return self.send_request(data)1111 #==================== 1112 def unsRegisteredNames(self): 1113 data={"jsonrpc": "2.0",1114 "method":"unsRegisteredNames",1115 "params": {1116 },1117 "filter": self.GENERICFILTER1118 }1119 logging.info( u'unsRegisteredNames method call' )1120 return self.send_request(data)1121 #==================== 1122 def summaryUnsRegisteredNames(self, fromDate, toDate): 1123 data={"jsonrpc": "2.0",1124 "method":"summaryUnsRegisteredNames",1125 "params": {1126 'fromDate' : fromDate,1127 'toDate' : toDate },1128 "filter": self.GENERICFILTER1129 }1130 logging.info( u'summaryUnsRegisteredNames method call' )1131 return self.send_request(data)1132 #==================== 1133 def getNetworkConnections(self): 1134 data={"jsonrpc": "2.0",1135 "method":"getNetworkConnections",1136 "params": {1137 },1138 "filter": self.GENERICFILTER1139 }1140 logging.info( u'getNetworkConnections method call' )1141 return self.send_request(data)1142 #==================== 1143 def getProxyMappings(self): 1144 data={"jsonrpc": "2.0",1145 "method":"getProxyMappings",1146 "params": {1147 },1148 "filter": self.GENERICFILTER1149 }1150 logging.info( u'getProxyMappings method call' )1151 return self.send_request(data)1152 #==================== 1153 def createProxyMapping(self, srcHost, srcPort, dstHost, dstPort, enabled): 1154 data={"jsonrpc": "2.0",1155 "method":"createProxyMapping",1156 "params": {1157 'srcHost' : srcHost,1158 'srcPort' : srcPort,1159 'dstHost' : dstHost,1160 'dstPort' : dstPort,1161 'enabled' : enabled },1162 "filter": self.GENERICFILTER1163 }1164 logging.info( u'createProxyMapping method call' )1165 return self.send_request(data)1166 #==================== 1167 def enableProxyMapping(self, mappingId): 1168 data={"jsonrpc": "2.0",1169 "method":"enableProxyMapping",1170 "params": {1171 'mappingId' : mappingId },1172 "filter": self.GENERICFILTER1173 }1174 logging.info( u'enableProxyMapping method call' )1175 return self.send_request(data)1176 #==================== 1177 def disableProxyMapping(self, mappingId): 1178 data={"jsonrpc": "2.0",1179 "method":"disableProxyMapping",1180 "params": {1181 'mappingId' : mappingId },1182 "filter": self.GENERICFILTER1183 }1184 logging.info( u'disableProxyMapping method call' )1185 return self.send_request(data)1186 #==================== 1187 def removeProxyMapping(self, mappingId): 1188 data={"jsonrpc": "2.0",1189 "method":"removeProxyMapping",1190 "params": {1191 'mappingId' : mappingId },1192 "filter": self.GENERICFILTER1193 }1194 logging.info( u'removeProxyMapping method call' )1195 return self.send_request(data)1196 #==================== 1197 def lowTrafficMode(self): 1198 data={"jsonrpc": "2.0",1199 "method":"lowTrafficMode",1200 "params": {1201 },1202 "filter": self.GENERICFILTER1203 }1204 logging.info( u'lowTrafficMode method call' )1205 return self.send_request(data)1206 #==================== 1207 def setLowTrafficMode(self, enabled): 1208 data={"jsonrpc": "2.0",1209 "method":"setLowTrafficMode",1210 "params": {1211 'enabled' : enabled },1212 "filter": self.GENERICFILTER1213 }1214 logging.info( u'setLowTrafficMode method call' )1215 return self.send_request(data)1216 #==================== 1217 def getWhoIsInfo(self, owner): 1218 data={"jsonrpc": "2.0",1219 "method":"getWhoIsInfo",1220 "params": {1221 'owner' : owner },1222 "filter": self.GENERICFILTER1223 }1224 logging.info( u'getWhoIsInfo method call' )1225 return self.send_request(data)1226 #==================== 1227 def requestTreasuryPoSRates(self): 1228 data={"jsonrpc": "2.0",1229 "method":"requestTreasuryPoSRates",1230 "params": {1231 },1232 "filter": self.GENERICFILTER1233 }1234 logging.info( u'requestTreasuryPoSRates method call' )1235 return self.send_request(data)1236 #==================== 1237 def getTreasuryPoSRates(self): 1238 data={"jsonrpc": "2.0",1239 "method":"getTreasuryPoSRates",1240 "params": {1241 },1242 "filter": self.GENERICFILTER1243 }1244 logging.info( u'getTreasuryPoSRates method call' )1245 return self.send_request(data)1246 #==================== 1247 def requestTreasuryTransactionVolumes(self): 1248 data={"jsonrpc": "2.0",1249 "method":"requestTreasuryTransactionVolumes",1250 "params": {1251 },1252 "filter": self.GENERICFILTER1253 }1254 logging.info( u'requestTreasuryTransactionVolumes method call' )1255 return self.send_request(data)1256 #==================== 1257 def getTreasuryTransactionVolumes(self): 1258 data={"jsonrpc": "2.0",1259 "method":"getTreasuryTransactionVolumes",1260 "params": {1261 },1262 "filter": self.GENERICFILTER1263 }1264 logging.info( u'getTreasuryTransactionVolumes method call' )1265 return self.send_request(data)1266 #==================== 1267 def ucodeEncode(self, hex_code, size_image, coder, format): 1268 data={"jsonrpc": "2.0",1269 "method":"ucodeEncode",1270 "params": {1271 'hex_code' : hex_code,1272 'size_image' : size_image,1273 'coder' : coder,1274 'format' : format },1275 "filter": self.GENERICFILTER1276 }1277 logging.info( u'ucodeEncode method call' )1278 return self.send_request(data)1279 #==================== 1280 def ucodeDecode(self, base64_image): 1281 data={"jsonrpc": "2.0",1282 "method":"ucodeDecode",1283 "params": {1284 'base64_image' : base64_image },1285 "filter": self.GENERICFILTER1286 }1287 logging.info( u'ucodeDecode method call' )1288 return self.send_request(data)1289 #==================== 1290 def getWebSocketState(self): 1291 data={"jsonrpc": "2.0",1292 "method":"getWebSocketState",1293 "params": {1294 },1295 "filter": self.GENERICFILTER1296 }1297 logging.info( u'getWebSocketState method call' )1298 return self.send_request(data)1299 #==================== 1300 def setWebSocketState(self, enabled, port): 1301 data={"jsonrpc": "2.0",1302 "method":"setWebSocketState",1303 "params": {1304 'enabled' : enabled,1305 'port' : port },1306 "filter": self.GENERICFILTER1307 }1308 logging.info( u'setWebSocketState method call' )1309 return self.send_request(data)1310 #==================== 1311 def clearTrayNotifications(self): 1312 data={"jsonrpc": "2.0",1313 "method":"clearTrayNotifications",1314 "params": {1315 },1316 "filter": self.GENERICFILTER1317 }1318 logging.info( u'clearTrayNotifications method call' )1319 return self.send_request(data)1320 #==================== 1321 def getContactGroups(self): 1322 data={"jsonrpc": "2.0",1323 "method":"getContactGroups",1324 "params": {1325 },1326 "filter": self.GENERICFILTER1327 }1328 logging.info( u'getContactGroups method call' )1329 return self.send_request(data)1330 #==================== 1331 def getContactsByGroup(self, groupName): 1332 data={"jsonrpc": "2.0",1333 "method":"getContactsByGroup",1334 "params": {1335 'groupName' : groupName },1336 "filter": self.GENERICFILTER1337 }1338 logging.info( u'getContactsByGroup method call' )1339 return self.send_request(data)1340 #==================== 1341 def renameContactGroup(self, oldGroupName, newGroupName): 1342 data={"jsonrpc": "2.0",1343 "method":"renameContactGroup",1344 "params": {1345 'oldGroupName' : oldGroupName,1346 'newGroupName' : newGroupName },1347 "filter": self.GENERICFILTER1348 }1349 logging.info( u'renameContactGroup method call' )1350 return self.send_request(data)1351 #==================== 1352 def deleteContactGroup(self, groupName): 1353 data={"jsonrpc": "2.0",1354 "method":"deleteContactGroup",1355 "params": {1356 'groupName' : groupName },1357 "filter": self.GENERICFILTER1358 }1359 logging.info( u'deleteContactGroup method call' )1360 return self.send_request(data)1361 #==================== 1362 def getTransfersFromManager(self): 1363 data={"jsonrpc": "2.0",1364 "method":"getTransfersFromManager",1365 "params": {1366 },1367 "filter": self.GENERICFILTER1368 }1369 logging.info( u'getTransfersFromManager method call' )1370 return self.send_request(data)1371 #==================== 1372 def getFilesFromManager(self): 1373 data={"jsonrpc": "2.0",1374 "method":"getFilesFromManager",1375 "params": {1376 },1377 "filter": self.GENERICFILTER1378 }1379 logging.info( u'getFilesFromManager method call' )1380 return self.send_request(data)1381 #==================== 1382 def abortTransfers(self, transferId): 1383 data={"jsonrpc": "2.0",1384 "method":"abortTransfers",1385 "params": {1386 'transferId' : transferId },1387 "filter": self.GENERICFILTER1388 }1389 logging.info( u'abortTransfers method call' )1390 return self.send_request(data)1391 #==================== 1392 def hideTransfers(self, transferId): 1393 data={"jsonrpc": "2.0",1394 "method":"hideTransfers",1395 "params": {1396 'transferId' : transferId },1397 "filter": self.GENERICFILTER1398 }1399 logging.info( u'hideTransfers method call' )1400 return self.send_request(data)1401 #==================== 1402 def getFile(self, fileId): 1403 data={"jsonrpc": "2.0",1404 "method":"getFile",1405 "params": {1406 'fileId' : fileId },1407 "filter": self.GENERICFILTER1408 }1409 logging.info( u'getFile method call' )1410 return self.send_request(data)1411 #==================== 1412 def deleteFile(self, fileId): 1413 data={"jsonrpc": "2.0",1414 "method":"deleteFile",1415 "params": {1416 'fileId' : fileId },1417 "filter": self.GENERICFILTER1418 }1419 logging.info( u'deleteFile method call' )1420 return self.send_request(data)1421 #==================== 1422 def sendFileByMessage(self, tohex, fileId): 1423 data={"jsonrpc": "2.0",1424 "method":"sendFileByMessage",1425 "params": {1426 'to' : tohex,1427 'fileId' : fileId },1428 "filter": self.GENERICFILTER1429 }1430 logging.info( u'sendFileByMessage method call' )1431 return self.send_request(data)1432 #==================== 1433 def getChannelBannedContacts(self, channelid): 1434 data={"jsonrpc": "2.0",1435 "method":"getChannelBannedContacts",1436 "params": {1437 'channelid' : channelid },1438 "filter": self.GENERICFILTER1439 }1440 logging.info( u'getChannelBannedContacts method call' )1441 return self.send_request(data)1442 #==================== 1443 def applyChannelBannedContacts(self, channelid, newList): 1444 data={"jsonrpc": "2.0",1445 "method":"applyChannelBannedContacts",1446 "params": {1447 'channelid' : channelid,1448 'newList' : newList },1449 "filter": self.GENERICFILTER1450 }1451 logging.info( u'applyChannelBannedContacts method call' )1452 return self.send_request(data)1453 #==================== 1454 def uploadFile(self, fileDataBase64, fileName): 1455 data={"jsonrpc": "2.0",1456 "method":"uploadFile",1457 "params": {1458 'fileDataBase64' : fileDataBase64,1459 'fileName' : fileName },1460 "filter": self.GENERICFILTER1461 }1462 logging.info( u'uploadFile method call' )1463 return self.send_request(data)1464 #==================== 1465 def sendChannelQuote(self, channelid, text, id_message): 1466 data={"jsonrpc": "2.0",1467 "method":"sendChannelQuote",1468 "params": {1469 'channelid' : channelid,1470 'text' : text,1471 'id_message' : id_message },1472 "filter": self.GENERICFILTER1473 }1474 logging.info( u'sendChannelQuote method call' )1475 return self.send_request(data)1476 #==================== 1477 def removeChannelMessage(self, channelid, id_message): 1478 data={"jsonrpc": "2.0",1479 "method":"removeChannelMessage",1480 "params": {1481 'channelid' : channelid,1482 'id_message' : id_message },1483 "filter": self.GENERICFILTER1484 }1485 logging.info( u'removeChannelMessage method call' )1486 return self.send_request(data)1487 #==================== 1488 def enableChannelNotification(self, channelid, enabled): 1489 data={"jsonrpc": "2.0",1490 "method":"enableChannelNotification",1491 "params": {1492 'channelid' : channelid,1493 'enabled' : enabled },1494 "filter": self.GENERICFILTER1495 }1496 logging.info( u'enableChannelNotification method call' ) ...

Full Screen

Full Screen

test_nvsdlib.py

Source:test_nvsdlib.py Github

copy

Full Screen

1# Copyright 2014 OneConvergence, Inc. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License"); you may4# not use this file except in compliance with the License. You may obtain5# a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the12# License for the specific language governing permissions and limitations13# under the License.14#15import mock16from oslo_serialization import jsonutils17from neutron.plugins.oneconvergence.lib import nvsdlib18from neutron.tests import base19NETWORKS_URI = "/pluginhandler/ocplugin/tenant/%s/lnetwork/"20NETWORK_URI = NETWORKS_URI + "%s"21GET_ALL_NETWORKS = "/pluginhandler/ocplugin/tenant/getallnetworks"22SUBNETS_URI = NETWORK_URI + "/lsubnet/"23SUBNET_URI = SUBNETS_URI + "%s"24GET_ALL_SUBNETS = "/pluginhandler/ocplugin/tenant/getallsubnets"25PORTS_URI = NETWORK_URI + "/lport/"26PORT_URI = PORTS_URI + "%s"27EXT_URI = "/pluginhandler/ocplugin/ext/tenant/%s"28FLOATING_IPS_URI = EXT_URI + "/floatingip/"29FLOATING_IP_URI = FLOATING_IPS_URI + "%s"30ROUTERS_URI = EXT_URI + "/lrouter/"31ROUTER_URI = ROUTERS_URI + "%s"32TEST_NET = 'test-network'33TEST_SUBNET = 'test-subnet'34TEST_PORT = 'test-port'35TEST_FIP = 'test-floatingip'36TEST_ROUTER = 'test-router'37TEST_TENANT = 'test-tenant'38class TestNVSDApi(base.BaseTestCase):39 def setUp(self):40 super(TestNVSDApi, self).setUp()41 self.nvsdlib = nvsdlib.NVSDApi()42 def test_create_network(self):43 network_obj = {44 "name": 'test-net',45 "tenant_id": TEST_TENANT,46 "shared": False,47 "admin_state_up": True,48 "router:external": False49 }50 resp = mock.Mock()51 resp.json.return_value = {'id': 'uuid'}52 with mock.patch.object(self.nvsdlib, 'send_request',53 return_value=resp) as send_request:54 uri = NETWORKS_URI % TEST_TENANT55 net = self.nvsdlib.create_network(network_obj)56 send_request.assert_called_once_with(57 "POST", uri,58 body=jsonutils.dumps(network_obj),59 resource='network',60 tenant_id=TEST_TENANT)61 self.assertEqual(net, {'id': 'uuid'})62 def test_update_network(self):63 network = {'id': TEST_NET,64 'tenant_id': TEST_TENANT}65 update_network = {'name': 'new_name'}66 uri = NETWORK_URI % (TEST_TENANT, TEST_NET)67 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:68 self.nvsdlib.update_network(network, update_network)69 send_request.assert_called_once_with(70 "PUT", uri, body=jsonutils.dumps(update_network),71 resource='network', tenant_id=TEST_TENANT,72 resource_id=TEST_NET)73 def test_delete_network(self):74 network = {'id': TEST_NET,75 'tenant_id': TEST_TENANT}76 uri = NETWORK_URI % (TEST_TENANT, TEST_NET)77 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:78 with mock.patch.object(self.nvsdlib, '_get_ports'):79 self.nvsdlib.delete_network(network)80 send_request.assert_called_once_with(81 "DELETE", uri, resource='network',82 tenant_id=TEST_TENANT, resource_id=TEST_NET)83 def test_create_port(self):84 path = PORTS_URI % (TEST_TENANT, TEST_NET)85 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:86 fixed_ips = [{'ip_address': '10.0.0.2',87 'subnet_id': TEST_SUBNET}]88 lport = {89 "id": TEST_PORT,90 "name": 'test',91 "device_id": "device_id",92 "device_owner": "device_owner",93 "mac_address": "mac_address",94 "fixed_ips": fixed_ips,95 "admin_state_up": True,96 "network_id": TEST_NET,97 "status": 'ACTIVE'98 }99 self.nvsdlib.create_port(TEST_TENANT, lport)100 expected = {"id": TEST_PORT, "name": 'test',101 "device_id": "device_id",102 "device_owner": "device_owner",103 "mac_address": "mac_address",104 "ip_address": '10.0.0.2',105 "subnet_id": TEST_SUBNET,106 "admin_state_up": True,107 "network_id": TEST_NET,108 "status": 'ACTIVE'}109 send_request.assert_called_once_with(110 "POST", path,111 body=jsonutils.dumps(expected),112 resource='port',113 tenant_id=TEST_TENANT)114 def test_update_port(self):115 port = {'id': TEST_PORT,116 'network_id': TEST_NET}117 port_update = {'name': 'new-name'}118 uri = PORT_URI % (TEST_TENANT, TEST_NET, TEST_PORT)119 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:120 self.nvsdlib.update_port(TEST_TENANT, port, port_update)121 send_request.assert_called_once_with(122 "PUT", uri,123 body=jsonutils.dumps(port_update),124 resource='port',125 resource_id='test-port',126 tenant_id=TEST_TENANT)127 def test_delete_port(self):128 port = {'network_id': TEST_NET,129 'tenant_id': TEST_TENANT}130 uri = PORT_URI % (TEST_TENANT, TEST_NET, TEST_PORT)131 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:132 self.nvsdlib.delete_port(TEST_PORT, port)133 send_request.assert_called_once_with("DELETE", uri,134 resource='port',135 tenant_id=TEST_TENANT,136 resource_id=TEST_PORT)137 def test_create_subnet(self):138 subnet = {'id': TEST_SUBNET,139 'tenant_id': TEST_TENANT,140 'network_id': TEST_NET}141 uri = SUBNETS_URI % (TEST_TENANT, TEST_NET)142 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:143 self.nvsdlib.create_subnet(subnet)144 send_request.assert_called_once_with("POST", uri,145 body=jsonutils.dumps(subnet),146 resource='subnet',147 tenant_id=TEST_TENANT)148 def test_update_subnet(self):149 subnet = {'id': TEST_SUBNET,150 'tenant_id': TEST_TENANT,151 'network_id': TEST_NET}152 subnet_update = {'name': 'new-name'}153 uri = SUBNET_URI % (TEST_TENANT, TEST_NET, TEST_SUBNET)154 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:155 self.nvsdlib.update_subnet(subnet, subnet_update)156 send_request.assert_called_once_with(157 "PUT", uri,158 body=jsonutils.dumps(subnet_update), resource='subnet',159 tenant_id=TEST_TENANT, resource_id=TEST_SUBNET)160 def test_delete_subnet(self):161 subnet = {'id': TEST_SUBNET,162 'tenant_id': TEST_TENANT,163 'network_id': TEST_NET}164 uri = SUBNET_URI % (TEST_TENANT, TEST_NET, TEST_SUBNET)165 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:166 self.nvsdlib.delete_subnet(subnet)167 send_request.assert_called_once_with("DELETE", uri,168 resource='subnet',169 tenant_id=TEST_TENANT,170 resource_id=TEST_SUBNET)171 def test_create_floatingip(self):172 floatingip = {'id': TEST_FIP,173 'tenant_id': TEST_TENANT}174 uri = FLOATING_IPS_URI % TEST_TENANT175 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:176 self.nvsdlib.create_floatingip(floatingip)177 send_request.assert_called_once_with(178 "POST", uri,179 body=jsonutils.dumps(floatingip),180 resource='floating_ip',181 tenant_id=TEST_TENANT)182 def test_update_floatingip(self):183 floatingip = {'id': TEST_FIP,184 'tenant_id': TEST_TENANT}185 uri = FLOATING_IP_URI % (TEST_TENANT, TEST_FIP)186 floatingip_update = {'floatingip': {'router_id': TEST_ROUTER}}187 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:188 self.nvsdlib.update_floatingip(floatingip, floatingip_update)189 send_request.assert_called_once_with(190 "PUT", uri,191 body=jsonutils.dumps(floatingip_update['floatingip']),192 resource='floating_ip', tenant_id=TEST_TENANT,193 resource_id=TEST_FIP)194 def test_delete_floatingip(self):195 floatingip = {'id': TEST_FIP,196 'tenant_id': TEST_TENANT}197 uri = FLOATING_IP_URI % (TEST_TENANT, TEST_FIP)198 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:199 self.nvsdlib.delete_floatingip(floatingip)200 send_request.assert_called_once_with(201 "DELETE", uri, resource='floating_ip', tenant_id=TEST_TENANT,202 resource_id=TEST_FIP)203 def test_create_router(self):204 router = {'id': TEST_ROUTER, 'tenant_id': TEST_TENANT}205 uri = ROUTERS_URI % TEST_TENANT206 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:207 self.nvsdlib.create_router(router)208 send_request.assert_called_once_with(209 "POST", uri, body=jsonutils.dumps(router), resource='router',210 tenant_id=TEST_TENANT)211 def test_update_router(self):212 router = {'id': TEST_ROUTER, 'tenant_id': TEST_TENANT}213 uri = ROUTER_URI % (TEST_TENANT, TEST_ROUTER)214 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:215 self.nvsdlib.update_router(router)216 send_request.assert_called_once_with(217 "PUT", uri, body=jsonutils.dumps(router),218 resource='router', tenant_id=TEST_TENANT,219 resource_id=TEST_ROUTER)220 def test_delete_router(self):221 uri = ROUTER_URI % (TEST_TENANT, TEST_ROUTER)222 with mock.patch.object(self.nvsdlib, 'send_request') as send_request:223 self.nvsdlib.delete_router(TEST_TENANT, TEST_ROUTER)224 send_request.assert_called_once_with(225 "DELETE", uri, resource='router',...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful