def testSprints(dataConnection): getAllSprintsQuery = ScrumblesData.Query.getAllSprints testSprint = ScrumblesObjects.Sprint() testSprint.sprintName = 'UniqueSprintName' testSprint.sprintStartDate = datetime.date(2018,1,31) testSprint.sprintDueDate = datetime.date(2018,2,27) testSprintCreationQuery = ScrumblesData.Query.createObject(testSprint) assert testSprintCreationQuery is not None dataConnection.connect() allSprintsQueryResult = dataConnection.getData(getAllSprintsQuery) dataConnection.setData(testSprintCreationQuery) allNewSprintsQueryResult = dataConnection.getData(getAllSprintsQuery) dataConnection.close() assert len(allNewSprintsQueryResult) != len(allSprintsQueryResult) testSprintSearchQuery = ScrumblesData.SprintQuery.getSprintBySprintID(testSprint.sprintID) assert testSprintSearchQuery is not None dataConnection.connect() foundTestSprintResult = dataConnection.getData(testSprintSearchQuery) dataConnection.close() foundSprint = ScrumblesObjects.Sprint(foundTestSprintResult[0]) assert foundSprint.sprintName == testSprint.sprintName dataConnection.connect() dataConnection.setData(ScrumblesData.Query.deleteObject(foundSprint)) foundTestSprintResult = dataConnection.getData(testSprintSearchQuery) dataConnection.close() assert foundTestSprintResult == () print('Sprint',testSprint.sprintID,' Data successfully created and deleted on remote server')
def testItems(dataConnection): testItem = ScrumblesObjects.Item() testItem.itemType = 'UNIT_TEST_2' testItem.itemTitle = 'UNIT_TEST_2' testItem.itemDescription = 'UNIT TESTING ITEM CREATION, previous test failed to delete' testItemCreationQuery = ScrumblesData.Query.createObject(testItem) assert testItemCreationQuery is not None dataConnection.connect() dataConnection.setData(testItemCreationQuery) testItemSearchQuery = ScrumblesData.CardQuery.getCardByCardID( testItem.itemID) testItemSearchResult = dataConnection.getData(testItemSearchQuery) retrievedItem = ScrumblesObjects.Item(testItemSearchResult[0]) dataConnection.close() assert retrievedItem.itemDescription == testItem.itemDescription dataConnection.connect() dataConnection.setData(ScrumblesData.Query.deleteObject(retrievedItem)) itemAfterDeletionQueryResult = dataConnection.getData( ScrumblesData.CardQuery.getCardByCardID(retrievedItem.itemID)) dataConnection.close() assert itemAfterDeletionQueryResult == () print('Item', testItem.itemID, ' Data successfully created and deleted on remote server')
def ok(self): item = ScrumblesObjects.Item oldItem = self.item item.itemID = oldItem.itemID item.itemTitle = self.itemTitleEntry.get() if item.itemTitle != oldItem.itemTitle: self.validateName(item.itemTitle) item.itemDescription = self.itemDescriptionEntry.get('1.0', 'end-1c') item.itemType = self.ItemTypebox.get() item.itemUserID = self.getSelectedUserID() sprintID, sprintDueDate = self.getSelectedSprintParams() item.itemSprintID = sprintID item.itemDueDate = sprintDueDate item.itemPriority = item.priorityTextToNumberMap[ self.itemPriorityCombobox.get()] item.itemCodeLink = self.itemCodeLinkEntry.get() item.itemStatus = self.discoverStatus(item) item.itemPoints = oldItem.itemPoints comment = ScrumblesObjects.Comment() comment.commentContent = self.commentTextBox.get('1.0', 'end-1c') comment.commentUserID = self.master.activeUser.userID comment.commentItemID = item.itemID if len(comment.commentContent) <= 0: raise Exception( 'Comment box cannot be blank\nPlease enter a change reason.') try: self.dataBlock.updateScrumblesObject(item, oldItem, comment) except IntegrityError: comment.commentID = ScrumblesObjects.generateRowID() self.dataBlock.updateScrumblesObject(item, oldItem, comment) messagebox.showinfo('Info', "Item '%s' Successfully Updated" % item.itemTitle) self.exit()
def assignToSprint(self, inSprint): sprint = None if messagebox.askyesno( 'Assign To Sprint', 'Do you wish to assign item to sprint %s?' % inSprint): for i in self.controller.activeProject.listOfAssignedSprints: if i.sprintName == inSprint: sprint = i if sprint is not None: try: title = self.selectedItem.itemTitle for j in self.controller.dataBlock.items: if j.itemTitle == title: item = j assert item is not None self.controller.dataBlock.assignItemToSprint(item, sprint) comment = ScrumblesObjects.Comment() comment.commentContent = '%s Has Assigned Item %s to Sprint' % ( self.controller.activeUser.userName, item.itemTitle) comment.commentItemID = item.itemID comment.commentUserID = self.controller.activeUser.userID self.controller.dataBlock.addNewScrumblesObject(comment) except Exception as e: messagebox.showerror('Error', str(e)) logging.exception('Error assigning item %s to sprint' % item.itemTitle) return messagebox.showinfo( 'Success', 'Item Assigned Item to sprint, %s' % sprint.sprintName) else: messagebox.showerror('Error', 'Sprint not found in DataBlock') logging.error('Sprint not found in dataBlock')
def assignItemToActiveUser(self): Item = self.backlogPopMenu.getSelectedObject() if Item.itemUserID is not None: messagebox.showerror( 'Error', 'Cannot Assign Item to Self!\nItem already assigned to another user' ) return False Comment = ScrumblesObjects.Comment() Comment.commentItemID = Item.itemID Comment.commentUserID = self.controller.activeUser.userID Comment.commentContent = 'Assigned to self by menu action' self.assignedItems.append(Item) self.userItemList.addItem(Item.itemTitle) self.updateProgressBar() result = messagebox.askyesno( 'Assign To Me', 'Do you want Assign this Item to yourself?') if result: try: self.controller.dataBlock.assignUserToItem( self.controller.activeUser, Item) self.controller.dataBlock.addNewScrumblesObject(Comment) messagebox.showinfo( 'Success', 'Item Assigned to %s' % self.controller.activeUser.userName) except Exception as e: logging.exception('Error Assigning Item to active User') messagebox.showerror('Error', str(e)) return True
def ok(self): project = ScrumblesObjects.Project() project.projectName = self.projectTitleEntry.get() self.validateName(project.projectName) try: if not self.isTest: self.dataBlock.addNewScrumblesObject(project) else: print('TESTMODE: self.dataBlock.addNewScrumblesObject(%s)' % repr(project)) except IntegrityError: logging.exception('ID Collision') project.projectID = ScrumblesObjects.generateRowID() self.dataBlock.addNewScrumblesObject(project) else: messagebox.showinfo('Info', 'New Item Successfully Created') self.exit()
def writeData(self,obj): try: self.dataBlock.addNewScrumblesObject(obj) except IntegrityError: logging.exception('ID Collision') obj.sprintID = ScrumblesObjects.generateRowID() self.dataBlock.addNewScrumblesObject(obj) else: messagebox.showinfo('Info', 'New Sprint Successfully Created')
def promoteItemToEpic(self, item): logging.info('Promoting Item %s to Epic' % item.itemTitle) oldItem = item comment = ScrumblesObjects.Comment() comment.commentContent = 'promoted item to epic' comment.commentItemID = item.itemID comment.commentUserID = 0 item.itemType = 'Epic' self.conn.setMulti(CardQuery.updateCard(item, oldItem, comment))
def modifyItemStatusByString(self, item, status): logging.info('Modifying item %s to status %s.' % (item.itemTitle, status)) oldItem = item item.itemStatus = item.statusTextToNumberMap[status] comment = ScrumblesObjects.Comment() comment.commentContent = 'Modify Item Status' comment.commentItemID = item.itemID comment.commentUserID = 0 self.conn.setMulti(CardQuery.updateCard(item, oldItem, comment))
def modifiyItemPriority(self, item, priority): logging.info('Modifying item %s priority to %s' % (item.itemTitle, item.priorityNumberToTextMap[priority])) assert priority in range(0, 3) oldItem = item item.itemPriority = priority comment = ScrumblesObjects.Comment() comment.commentContent = 'item priority changed' comment.commentItemID = item.itemID comment.commentUserID = 0 self.conn.setMulti(CardQuery.updateCard(item, oldItem, comment))
def assignItemToSprint(self, item, sprint): logging.info('Assigning Item %s to Sprint %s.' % (item.itemTitle, sprint.sprintName)) oldItem = item item.itemSprintID = sprint.sprintID item.itemDueDate = sprint.sprintDueDate comment = ScrumblesObjects.Comment() comment.commentContent = 'item assigned to sprint' comment.commentItemID = item.itemID comment.commentUserID = 0 self.conn.setMulti(CardQuery.updateCard(item, oldItem, comment))
def removeItemFromSprint(self, item): logging.info('Removing Item %s from sprint %s.' % (item.itemTitle, str(item.itemSprintID))) oldItem = item item.itemSprintID = 0 comment = ScrumblesObjects.Comment() comment.commentContent = 'item removed from sprint' comment.commentItemID = item.itemID comment.commentUserID = 0 self.conn.setMulti(CardQuery.updateCard(item, oldItem, comment))
def ok(self): self.validatePasswordMatch(self.passwordEntry.get(), self.reEnterPasswordEntry.get()) user = ScrumblesObjects.User() user.userName = self.userNameEntry.get() user.userPassword = self.passwordEntry.get() user.userEmailAddress = self.emailEntry.get() user.userRole = self.roleCombobox.get() self.validateName(user.userName) try: if not self.isTest: self.dataBlock.addNewScrumblesObject(user) except IntegrityError: logging.exception('ID Collision') user.userID = ScrumblesObjects.generateRowID() self.dataBlock.addNewScrumblesObject(user) else: messagebox.showinfo('Info', 'New User Successfully Created') self.exit()
def ok(self): if self.item is None: item = ScrumblesObjects.Item() else: item = self.item item.itemTitle = self.itemTitleEntry.get() item.itemDescription = self.itemDescriptionEntry.get('1.0', 'end-1c') item.itemType = self.ItemTypebox.get() item.itemPoints = self.pointsEntry.get() item.itemPriority = item.priorityTextToNumberMap[ self.itemPriorityCombobox.get()] self.validateName(item.itemTitle) comment = ScrumblesObjects.Comment() comment.commentContent = self.commentTextBox.get('1.0', 'end-1c') if not self.isTest: comment.commentUserID = self.parent.activeUser.userID comment.commentItemID = item.itemID if not self.isTest: self.writeData(item, comment) self.exit()
def writeData(self, item, comment): if not item.itemPoints.isdigit(): raise Exception('Points must be a number') try: self.dataBlock.addNewScrumblesObject(item) except IntegrityError: logging.exception('ID Collision') item.itemID = ScrumblesObjects.generateRowID() comment.commentItemID = item.itemID self.dataBlock.addNewScrumblesObject(item) if len(comment.commentContent) > 0: try: self.dataBlock.addNewScrumblesObject(comment) except IntegrityError: comment.commentID = ScrumblesObjects.generateRowID() self.dataBlock.addNewScrumblesObject(comment) else: messagebox.showinfo('Info', 'New Item Successfully Created') self.dataBlock.addItemToProject(self.parent.activeProject, item)
def ok(self): self.executeSuccess = True oldItem = self.Item comment = ScrumblesObjects.Comment() comment.commentContent = 'modify code link' comment.commentItemID = self.Item.itemID comment.commentUserID = 0 self.Item.itemCodeLink = self.codeLinkEntry.get() if not self.isTest: self.dataBlock.updateScrumblesObject(self.Item, oldItem, comment) self.exit()
def modifyItemStatus(self, item, status): logging.info('Modifying item %s status to %s' % (item.itemTitle, item.statusNumberToTextMap[status])) assert status in range(0, 5) oldItem = item item.itemStatus = item.statusNumberToTextMap[status] comment = ScrumblesObjects.Comment() comment.commentContent = 'modify item status' comment.commentItemID = item.itemID comment.commentUserID = 0 try: self.conn.setMulti(CardQuery.updateCard(item, oldItem, comment)) except Exception as e: item.itemStatus = oldItem.itemStaus raise e
def assignUserToItem(self, user, item): oldItem = item if user is not None: logging.info('Assigning User %s to item %s.' % (user.userName, item.itemTitle)) item.itemUserID = user.userID item.itemStatus = item.statusTextToNumberMap['Assigned'] else: logging.info('Assinging None User to item %s.' % item.itemTitle) item.itemUserID = None item.itemStatus = item.statusTextToNumberMap['Not Assigned'] comment = ScrumblesObjects.Comment() comment.commentContent = 'Assign user to item' comment.commentItemID = item.itemID comment.commentUserID = 0 self.conn.setMulti(CardQuery.updateCard(item, oldItem, comment))
def submitComment(self, event=None): newComment = ScrumblesObjects.Comment() newComment.commentContent = self.newCommentField.get("1.0", tk.END) newComment.commentContent = str(newComment.commentContent) newComment.commentContent = newComment.commentContent.strip() newComment.commentTimeStamp = datetime.datetime.now() newComment.commentSignature = self.master.activeUser.userName + " " + datetime.datetime.now( ).strftime("%I:%M %p, %m/%d/%y") newComment.commentUserID = self.master.activeUser.userID newComment.commentItemID = self.inspection.itemID self.newCommentField.delete("1.0", tk.END) if newComment.commentContent: #check for empty string self.comments.append(newComment) self.renderCommentField(initializedComments=True) self.master.dataBlock.addNewScrumblesObject(newComment)
def removeFromEpic(self): item = None try: title = self.selectedItem.itemTitle for i in self.controller.dataBlock.items: if i.itemTitle == title: item = i self.controller.dataBlock.removeItemFromEpic(item) comment = ScrumblesObjects.Comment() comment.commentContent = '%s Has Removed Item from epic' % self.controller.activeUser.userName comment.commentItemID = item.itemID comment.commentUserID = self.controller.activeUser.userID self.controller.dataBlock.addNewScrumblesObject(comment) except Exception as e: logging.exception('Could not remove item from epic') messagebox.showerror('Error', str(e)) messagebox.showinfo('Success', 'Item Removed')
def ok(self): if self.sprint is None: sprint = ScrumblesObjects.Sprint() else: sprint = self.sprint sprint.sprintName = self.sprintNameEntry.get() sprint.sprintStartDate = self.getDate('start') sprint.sprintDueDate = self.getDate('due') if self.oldSprintName is None or self.oldSprintName != sprint.sprintName: self.validateName(sprint.sprintName) if not self.isTest: projectName = self.assignSprintToObject.get() for P in self.dataBlock.projects: if P.projectName == projectName: sprint.projectID = P.projectID if not self.isTest: self.writeData(sprint) self.exit()
def assignToEpic(self, inEpic): epic = None if messagebox.askyesno( 'Assign To Epic', 'Do you wish to assign item to Epic %s?' % inEpic): for i in self.controller.activeProject.listOfAssignedItems: if i.itemType == 'Epic': if i.itemTitle == inEpic: epic = i if epic is not None: try: title = self.selectedItem.itemTitle for j in self.controller.dataBlock.items: if j.itemTitle == title: item = j assert item is not None self.controller.dataBlock.addItemToEpic(item, epic) comment = ScrumblesObjects.Comment() comment.commentContent = '%s Has Assigned Item %s to Epic' % ( self.controller.activeUser.userName, item.itemTitle) comment.commentItemID = item.itemID comment.commentUserID = self.controller.activeUser.userID self.controller.dataBlock.addNewScrumblesObject(comment) except Exception as e: messagebox.showerror('Error', str(e)) logging.exception('Error assigning item %s to epic' % item.itemTitle) return messagebox.showinfo( 'Success', 'Item Assigned Item to Epic, %s' % epic.itemTitle) else: messagebox.showerror('Error', 'Epic not found in DataBlock') logging.error('Epic not found in dataBlock')
print(item.itemID) print(item.itemType) print(item.itemTitle) print(item.itemDescription) print(item.itemCreationDate) print(item.itemDueDate) print(item.itemCodeLink) print(item.itemSprintID) print(item.itemUserID) print(item.itemStatus) login_info = ScrumblesData.DataBaseLoginInfo() login_info.userID = 'test_user' login_info.password = '******' login_info.ipaddress = '173.230.136.241' login_info.defaultDB = 'test' dataConnection = ScrumblesData.ScrumblesData(login_info) dataConnection.connect() itemTable = dataConnection.getData(ScrumblesData.Query.getAllCards) dataConnection.close() listOfAllItems = [] for row in itemTable: item = ScrumblesObjects.Item(row) listOfAllItems.append(item) for item in listOfAllItems: printItemDetails(item)
assert len(allCommentsQueryResult) >= 0 print('Data Download Successful') listOfUsers = [] listOfSprints = [] listOfItems = [] listOfComments = [] ## Test construction of Objects from Query Results for element in allUsersQueryResult: assert len(element) == 5 assert 'UserID' in element assert 'UserName' in element assert 'UserEmailAddress' in element assert 'UserPassword' in element assert 'UserRole' in element user = ScrumblesObjects.User(element) assert user.userID == element['UserID'] assert user.userName == element['UserName'] assert user.userEmailAddress == element['UserEmailAddress'] assert user.userPassword == element['UserPassword'] assert user.userRole == element['UserRole'] listOfUsers.append(user) assert len(listOfUsers) == len(allUsersQueryResult) for element in allSprintsQueryResult: #assert len(element) == 4 this is dumb, number of sprints change assert 'SprintID' in element assert 'StartDate' in element assert 'DueDate' in element assert 'SprintName' in element sprint = ScrumblesObjects.Sprint(element)
PASS = '******' FAIL = '\033[91m' SLEEP = 3 logging.basicConfig(format='%(levelname)s: %(asctime)s: %(message)s', filename='ScrumblesTest.log', level=logging.DEBUG) logging.info('Application starting') testRun = {} db = DataBlock.DataBlock(mode='test') db.updateAllObjects() Tsprint = ScrumblesObjects.Sprint() Tsprint.sprintName = 'TUnit Test' Tsprint.sprintStartDate = datetime.now() Tsprint.sprintDueDate = datetime.now() Tsprint.projectID = 0 print(type(Tsprint)) print(repr(Tsprint)) print(type(Tsprint) is ScrumblesObjects.Sprint) print(type(Tsprint) is data.ScrumblesObjects.Sprint) TItem = ScrumblesObjects.Item() TItem.itemTitle = "Test Item to add to Test Sprint" TItem.itemDescription = 'Test TEST TEST' TItem.itemPriority = 0 TItem.itemStatus = 0
from data import ScrumblesData, ScrumblesObjects def printUserDetails(user): print(user.userID) print(user.userName) print(user.userEmailAddress) print(user.userRole) print() login_info = ScrumblesData.DataBaseLoginInfo() login_info.userID = 'test_user' login_info.password = '******' login_info.ipaddress = '173.230.136.241' login_info.defaultDB = 'test' dataConnection = ScrumblesData.ScrumblesData(login_info) dataConnection.connect() userTable = dataConnection.getData(ScrumblesData.Query.getAllUsersQuery) dataConnection.close() listOfAllUsers = [] for row in userTable: user = ScrumblesObjects.User(row) listOfAllUsers.append(user) for user in listOfAllUsers: printUserDetails(user)
def updateAllObjects(self): if self.firstLoad: time.sleep(1) self.isLoading = True funcStartTime = time.clock() self.conn.connect() self.users.clear() self.items.clear() self.projects.clear() self.comments.clear() self.tags.clear() self.sprints.clear() self.itemMap = {} self.sprintMap = {} self.commentMap = {} self.projectMap = {} self.userMap = {} #print('getting tables') loopStartTime = time.clock() userTable = self.conn.getData(Query.getAllUsers) itemTable = self.conn.getData(Query.getAllCards) projectTable = self.conn.getData(Query.getAllProjects) commentTable = self.conn.getData(Query.getAllComments) sprintTable = self.conn.getData(Query.getAllSprints) userToProjectRelationTable = self.conn.getData(Query.getAllUserProject) itemToProjectRelationTable = self.conn.getData(Query.getAllProjectItem) itemTimeLineTable = self.conn.getData('SELECT * FROM CardTimeLine') epicTable = self.conn.getData('SELECT * FROM EpicTable') self.conn.close() #print('Tables loaded in %fms' % ((time.clock()-loopStartTime)*1000) ) loopStartTime = time.clock() #print('splicing vectors') timeLineMap = self.mapTimeline(itemTimeLineTable) epicMap = self.buildEpicMap(epicTable) for comment in commentTable: Comment = ScrumblesObjects.Comment(comment) self.comments.append(Comment) self.commentMap[Comment.commentID] = Comment #print('Comment List Built in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for item in itemTable: Item = ScrumblesObjects.Item(item) Item.listOfComments = [ C for C in self.comments if C.commentItemID == Item.itemID ] self.applyItemLine(Item, timeLineMap) # try: # Item.itemTimeLine = timeLineMap[Item.itemID] # except KeyError: # timeLineMap = self.reloadTimeLineMap() if 'AssignedToSPrint' in Item.itemTimeLine: Item.itemTimeLine['AssignedToSprint'] = Item.itemTimeLine[ 'AssignedToSPrint'] #self.populateItemTimeLine(Item,timeLineMap) self.itemMap[Item.itemID] = Item self.items.append(Item) #print('Item List Built in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for I in self.items: if I.itemID in epicMap: #epicMap[subitemID]->EpicID self.itemMap[epicMap[I.itemID]].subItemList.append( I) #itemMap[itemID]->Item #print('Item subitems spliced in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for user in userTable: User = ScrumblesObjects.User(user) User.listOfAssignedItems = [ I for I in self.items if I.itemUserID == User.userID ] User.listOfComments = [ C for C in self.comments if C.commentUserID == User.userID ] self.users.append(User) self.userMap[User.userID] = User #print('User List Built in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for sprint in sprintTable: Sprint = ScrumblesObjects.Sprint(sprint) Sprint.listOfAssignedItems = [ I for I in self.items if I.itemSprintID == Sprint.sprintID ] Sprint.listOfAssignedUsers = [ U for U in self.users if U.userID in [I.itemUserID for I in Sprint.listOfAssignedItems] ] self.sprints.append(Sprint) self.sprintMap[Sprint.sprintID] = Sprint #print('Sprint List Built in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for project in projectTable: Project = ScrumblesObjects.Project(project) Project.listOfAssignedSprints = [ S for S in self.sprints if S.projectID == Project.projectID ] self.projects.append(Project) self.projectMap[Project.projectID] = Project #print('Project List Built in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for user in self.users: for dict in userToProjectRelationTable: if dict['UserID'] == user.userID: for project in self.projects: if dict['ProjectID'] == project.projectID: user.listOfProjects.append(project) #print('Users Spliced to Projects in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for project in self.projects: for dict in userToProjectRelationTable: if dict['ProjectID'] == project.projectID: for user in self.users: if dict['UserID'] == user.userID: project.listOfAssignedUsers.append(user) #print('Projects spliced to users in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for dict in itemToProjectRelationTable: if dict['ProjectID'] == project.projectID: for item in self.items: if dict['ItemID'] == item.itemID: item.projectID = project.projectID project.listOfAssignedItems.append(item) #print('Items Spliced to Projects in %fms' % ((time.clock() - loopStartTime) * 1000)) #self.debugDump() #print('Data Loaded in %fs' % (time.clock()-funcStartTime)) self.isLoading = False return True