def test_commitCloseACard(self): verbs = [ "close", "closes", "closed", "Close", "Closes", "Closed", "CLOSE", "CLOSES", "CLOSED", "cLoSE", "CloSES", "clOSeD" ] for verb in verbs: # Make sure the card is not closed put_load = {'closed': 'false', 'token': TOKEN, 'key': API_KEY} requests.put(BASE_URL + "/cards/%s" % self.cardIdFull, data=put_load) message = verb + " tr#%s with these changes." % self.cardIdShort commit = {'message': message} self.broker.handleCommit(commit) params = { 'actions': 'commentCard', 'members': 'true', 'fields': 'closed' } card = getCard(self, params) comment = card['actions'][0] # Should comment, assign, and close self.assertEqual(comment["data"]["text"], message) self.assertTrue(self.author in card['members']) self.assertTrue(card['closed'])
def test_commitCloseACard(self): verbs = [ "close", "closes", "closed", "Close", "Closes", "Closed", "CLOSE", "CLOSES", "CLOSED", "cLoSE", "CloSES", "clOSeD" ] for verb in verbs: # Make sure the card is not closed put_load = {'closed': 'false', 'token': TOKEN, 'key': API_KEY} requests.put(BASE_URL + "/cards/%s" % self.cardIdFull, data=put_load) message = verb + " tr#%s with these changes." % self.cardIdShort commit = {'message': message} self.broker.handleCommit(commit) params = {'actions': 'commentCard', 'members': 'true', 'fields': 'closed'} card = getCard(self, params) comment = card['actions'][0] # Should comment, assign, and close self.assertEqual(comment["data"]["text"], message) self.assertTrue(self.author in card['members']) self.assertTrue(card['closed'])
def closeCard(self, cardId, commit): """Post the commit message as a comment and close the card. Keyword arguments: cardId -- the id of the card to perform actions to. commit -- the commit dict with message to comment. """ # Comment the commit to the card self.referenceCard(cardId, commit) # Close / Archive the card put_load = {'closed': 'true', 'token': self.token, 'key': API_KEY} requests.put(CARD_URL % self.__cardMap[cardId], data=put_load)
def closeCard(self, cardId, commit): """Post the commit message as a comment and close the card. Keyword arguments: cardId -- the id of the card to perform actions to. commit -- the commit dict with message to comment. """ # Comment the commit to the card self.referenceCard(cardId, commit) # Close / Archive the card put_load = {"closed": "true", "token": self.token, "key": API_KEY} requests.put(CARD_URL % self.__cardMap[cardId], data=put_load)
def update_param(username, password, application_name, param_name, param_value): """ Update Parameter :param username: Admin Username :type username: str :param password: Admin Password :type password: str :param application_name: Application Name to which the Parameter is Associated :type application_name: str :param param_name: Parameter Name :type param_name: str :param param_value: New Parameter Value :type param_value: str :return: Updated Param :rtype: dict """ param = requests.put(os.getenv("key_server_site") + "/rest/param/update?app=" + application_name, auth=(username, password), json={ "name": param_name, "value": param_value }) try: assert param.status_code == 202 return param.json() except AssertionError: exit("Problem Updating Param (Check Server Logs for Details) - HTTP Status: %i" % param.status_code)
def update_param(username, password, application_name, param_name, param_value): """ Update Parameter :param username: Admin Username :type username: str :param password: Admin Password :type password: str :param application_name: Application Name to which the Parameter is Associated :type application_name: str :param param_name: Parameter Name :type param_name: str :param param_value: New Parameter Value :type param_value: str :return: Updated Param :rtype: dict """ param = requests.put(os.getenv("key_server_site") + "/rest/param/update?app=" + application_name, auth=(username, password), json={ "name": param_name, "value": param_value }) try: assert param.status_code == 202 return param.json() except AssertionError: exit( "Problem Updating Param (Check Server Logs for Details) - HTTP Status: %i" % param.status_code)
def update_user(admin_username, admin_password, username, password=None, email=None): """ Update a User :param admin_username: Admin Username :type admin_username: str :param admin_password: Admin Password :type admin_password: str :param username: Username for User :type username: str :param password: New Password for User :type password: str :param email: New Email Address for User :type email: str :return: Updated User :rtype: dict """ if password is not None: password = base64.b64encode(password) user = requests.put(os.getenv("key_server_site") + "/rest/user/update", auth=(admin_username, admin_password), json={"username": username, "password": password, "email": email}) try: assert user.status_code == 202 return user.json() except AssertionError: exit("Problem updating user (Check Server Logs for Details) - HTTP Status: %i" % user.status_code)
def update_key(username, password, application_key, application_name=None, permissions=None): """ Update API Key :param username: Admin Username :type username: str :param password: Admin Password :type password: str :param application_key: Application Key to Update :type application_key: str :param application_name: New Application Name :type application_name: str :param permissions: New Application Permissions :type permissions: str :return: Updated API Key :rtype: dict """ key = requests.put( os.getenv("key_server_site") + "/rest/key/update", auth=(username, password), json={"application_key": application_key, "application_name": application_name, "permissions": permissions}, ) try: assert key.status_code == 202 return key except AssertionError: exit("Problem Updating Key (Check Server Logs for Details) - HTTP Status: %i" % key.status_code)
def update_key(username, password, application_key, application_name=None, permissions=None): """ Update API Key :param username: Admin Username :type username: str :param password: Admin Password :type password: str :param application_key: Application Key to Update :type application_key: str :param application_name: New Application Name :type application_name: str :param permissions: New Application Permissions :type permissions: str :return: Updated API Key :rtype: dict """ key = requests.put(os.getenv("key_server_site") + "/rest/key/update", auth=(username, password), json={ "application_key": application_key, "application_name": application_name, "permissions": permissions }) try: assert key.status_code == 202 return key except AssertionError: exit( "Problem Updating Key (Check Server Logs for Details) - HTTP Status: %i" % key.status_code)