def test_project_update(self): a = Project('Project A', 'Work on A') project_id = self._project_manager.add_project(a) b = Project('Project B', 'Work on B') self._project_manager.update_project(project_id, b) updated_project = self._project_manager.find_project_by_id(project_id) self.assertEqual(updated_project.name, b.name) self.assertEqual(updated_project.description, b.description)
def test_project_remove(self): a = Project('Project A', 'Work on A') a_id = self._project_manager.add_project(a) b = Project('Project B', 'Work on B') b_id = self._project_manager.add_project(b) self.assertEqual(self._project_manager.count_projects(), 2) self._project_manager.remove_project(a_id) project = self._project_manager.find_project_by_id(b_id) self.assertEqual(project.name, 'Project B') self.assertEqual(self._project_manager.count_projects(), 1)
def test_find_project_by_id(self): a = Project('Project A', 'Work on A') b = Project('Project B', 'Work on B') a_id = self._project_manager.add_project(a) b_id = self._project_manager.add_project(b) project = self._project_manager.find_project_by_id(a_id) self.assertEqual(project.name, 'Project A') self.assertEqual(project.description, 'Work on A') project = self._project_manager.find_project_by_id(b_id) self.assertEqual(project.name, 'Project B') self.assertEqual(project.description, 'Work on B')
def test_find_projects_by_name(self): a = Project('Initialization', 'Work on A') b = Project('Progress', 'Work on B') c = Project('Final steps', 'Work on C') self._project_manager.add_project(a) self._project_manager.add_project(b) self._project_manager.add_project(c) result = self._project_manager.find_projects_by_name('in') self.assertEqual(len(result), 2) result = self._project_manager.find_projects_by_name('in progress') self.assertEqual(len(result), 0) result = self._project_manager.find_projects_by_name('PROGRESS') self.assertEqual(len(result), 1)
def project(context, l, c, namespace, name): activeGitlab = context.obj['active_gitlab'] project = Project(projects = activeGitlab.projects, namespaces=activeGitlab.namespaces) if l: projects = project.listProjectsPaths() for proj in projects: print(proj) if c: project.createProject(namespace=namespace, name=name)
def test_listProjectsPaths(self, list): print('starting now to auth') auth = Auth(username=logindetails.user, token=logindetails.token) activeGitlab = auth.authorizeUser() # create a Project object called project project = Project(projects=activeGitlab.projects, namespaces=activeGitlab.namespaces) # call the function to listProject paths - The API list function is mocked to return the Mockproject objects projpaths = project.listProjectsPaths() print(projpaths)
def test_properties(self): members = [1, 2, 3] documents = [4, 5, 6] project = Project('project_1', 'The first project', members=members, documents=documents) self.assertEqual(project.name, 'project_1') self.assertEqual(project.description, 'The first project') self.assertEqual(project.members, [1, 2, 3]) self.assertEqual(project.documents, [4, 5, 6])
def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.connectActions() self.videoAnnoWidget = VideoAnnoWidget(self) self.setCentralWidget(self.videoAnnoWidget) self.project: Project = Project() self.appSettings: AppSettings = AppSettings() self.loadAppSettings()
def read_file(self, month, year, file): wb_r = xlrd.open_workbook(file) sheet1 = wb_r.sheet_by_name(month + year) nrow = sheet1.nrows ncol = sheet1.ncols self.project_dates_col = sheet1.col_values(0) for i in range(1, ncol): project_obj = Project(sheet1.cell_value(0, i)) for j in range(1, nrow): date_row = sheet1.cell_value(j, 0) words = sheet1.cell_value(j, i) project_obj.list_of_occurrences.append([date_row, words]) self.main_list.append(project_obj)
def update_file(self, day, month, new_project, new_words): today = day + " " + month temp_project = Project(new_project) if today not in self.project_dates_col: self.project_dates_col.append(today) index_proj = 9999 project_exists = False project_date_exists = False index_date = 9999 # checks if project project exists and get its index in the main list for index, project in enumerate(self.main_list): if project.get_name() == new_project: index_proj = index project_exists = True print(index_proj) if project_exists == True: for date_proj, data_pair in enumerate(self.main_list[index_proj].list_of_occurrences): print(data_pair[0]) if data_pair[0] == today: index_date = date_proj project_date_exists = True print(index_date) if project_date_exists == True: self.main_list[index_proj].list_of_occurrences[index_date][1] = new_words else: self.main_list[index_proj].list_of_occurrences.append([today, new_words]) if project_exists == False: temp_project.list_of_occurrences.append([today, new_words]) print(temp_project.list_of_occurrences) self.main_list.append(temp_project)
def add_project(self): user_name = raw_input("User name: ") for account in Account.objects: if account.username == user_name: user_account = account self.title = raw_input("Project title: ") self.contact = raw_input("Project contact: ") self.results = raw_input("Results: ") self.nsf_Aggreement = raw_input("NSF Aggreement (Yes or No): ") self.slide_collection_aggreement = raw_input( "Slide Collection Aggreement (Yes or No): ") self.other = raw_input("Other: ") project = Project( project_title=self.title, lead=user_account, manager=user_account, contact=self.contact, results=self.results, nsf_Aggreement=self.nsf_Aggreement, slide_collection_aggreement=self.slide_collection_aggreement, other=self.other) project.save() print project.project_title
def test_creation(self): project = Project('project_1', 'The first project')
class GitlabManager: #"""This is the main Class""" print('starting now to auth') auth = Auth(username=logindetails.user, token=logindetails.token) activeGitlab = auth.authorizeUser() #create a Project object called project project = Project(projects=activeGitlab.projects, namespaces=activeGitlab.namespaces) projpaths = project.listProjectsPaths() print('These are your Projects') for p in projpaths: print(p) #comment for key in ProjectList: projectname = key #print(projectname) projectnamespace = ProjectList[key] #print(projectnamespace) pathname = (projectnamespace + '/' + projectname) pathnamelower = pathname.lower() #print(pathnamelower) #check if the projects on ProjectList exist on Gitlab - If not add them to Gitlab - If exists then write the standard pushrules project_in_Gitlab = project.checkifprojectexistonGitlab(pathnamelower) if project_in_Gitlab is None: print('creating a new project called ' + pathnamelower) newproj = project.createProject(namespace=projectnamespace, name=projectname) print(newproj.pushrules.get()) print(newproj.attributes) else: project.updateProjectpushrules(project_in_Gitlab) print( 'The project ' + pathnamelower + ' already exists - no new project created - Push rules updated' ) #check if the projects on Gitlab still remain on the ProjectList - if not remove them from Gitlab for p in projpaths: print(p['name']) project_on_list = False for key in ProjectList: projectnameonlist = key #print(projectnameonlist) projectnamespaceonlist = ProjectList[key] #print(projectnamespaceonlist) pathname = (projectnamespaceonlist + '/' + projectnameonlist) pathnamelower = pathname.lower() #print(pathnamelower) #check if the project on Gitlab exists on ProjectList - If not remove from Gitlab if (p['name'] == pathnamelower): project_on_list = True print( 'setting Gitlab project on list to True-No action required' ) break if not (project_on_list): print( 'removing the following project from Gitlab no longer on list ' + p['name'].lower()) project.deleteProject(p['id']) # create a Namespaces object called namespaces namespaces = Namespaces(activeGitlab.namespaces) namespaceList = namespaces.listNamespaces() print('These are all the namespaces') for n in namespaceList: print(n) # create a Groups object called groups groups = Groups(activeGitlab.groups) groupList = groups.listGroups() print('These are all the groups') for g in groupList: print(g) print('These are all the Members in the Group TestGitLabManage') members = groups.listGroupMembers('TestGitLabManage') for m in members: print(m)
def test_creation_with_documents(self): documents = [1, 2, 3] project = Project('project_1', 'The first project', documents=documents)
def test_multiple_project_addition(self): for i in range(100): project = Project('Project {}'.format(i), 'Common project') self._project_manager.add_project(project) self.assertEqual(self._project_manager.count_projects(), 100)
def set_project(self, github, jira): self.project = Project(github.lower(), jira.upper()) self.set_extractor()
def test_creation_with_members(self): members = [1, 2, 3] project = Project('project_1', 'The first project', members=members)
def test_project_remove_with_invalid_id(self): a = Project('Project A', 'Work on A') a_id = self._project_manager.add_project(a) with self.assertRaises(ValueError): self._project_manager.remove_project(a_id + 1)
def test_project_update_with_invalid_id(self): with self.assertRaises(ValueError): a = Project('Project A', 'Work on A') project_id = self._project_manager.add_project(a) b = Project('Project B', 'Work on B') self._project_manager.update_project(project_id + 1, b)
x = entries[i] kinds = [my_dict['kind'] for my_dict in x[4]] actions = [my_dict['action'] for my_dict in x[4]] projects = [] for i in range(len(x[3])): curr_path = x[3][i] size_to_add = 0 if kinds[i] == 'file': size_to_add = parse_list(list_file, curr_path.replace('/mjschau2/', '')) svn_link = str( 'https://subversion.ews.illinois.edu/svn/sp17-cs242' + curr_path + '/?p=' + x[0]['revision']) temp_proj = proj.Project(curr_path, size_to_add, actions[i], kinds[i], text=svn_link, file_id=curr_id) result = files.insert_one(temp_proj.__dict__) #print(result) curr_id += 1 projects.append(temp_proj.__dict__) temp_obj = le.log_entry(int(x[0]['revision']), x[1], x[2], x[5], projects) entry_objs.append(temp_obj.__dict__) project_data = entry_objs #now put up on mongodb database result = logs.insert_many(project_data)
def find_projects(dirpath, excludes, depth, name_for_parent=1): """Return list of directories containing a `.git` file or directory Results matching globbing patterns in `excludes` will be ignored. `depth` is how many directories deep to search (2 is the minimum in most situations). `name_for_parent` is which level of the directory hierarchy to name the repo after relative to `.git` (1=immediate parent, 2=grandparent) """ start = time() cmdFindProjects = [ 'find', '-L', dirpath, '-type', 'd', '-not', '-name', '".*"', '-depth', str(depth) ] output = subprocess.check_output(cmdFindProjects) output = [s.strip() for s in decode(output).split('\n') if s.strip()] results = [] for filepath in output: project_is_repo = False components = filepath.rstrip('/').split('/') name = os.path.basename(os.path.normpath(filepath)) # search sub repos cmdFindRepos = [ 'find', '-L', filepath, '-name', '.git', '-maxdepth', '3' ] output2 = subprocess.check_output(cmdFindRepos) output2 = [ os.path.dirname(s.strip()) for s in decode(output2).split('\n') if s.strip() ] for filepath2 in output2: components2 = filepath2.rstrip('/').split('/') components_diff = components2[len(components):] name2 = name + "/" + "/".join(components_diff) #components2[-1] if filepath == filepath2: project_is_repo = True else: results.append(Project(name2, filepath2, "repository")) # add Project results.append( Project( name, filepath, "project" if not project_is_repo else "project_repository")) log.debug(u'%d project(s) found in `%s` in %0.2fs', len(results), dirpath, time() - start) for r in results: log.debug(' %r', r) return results
def newProject(self): self.saveProject() se = Project() self.loadProject(se)
def test_add_project(self): project = Project('My Project', 'A very difficult project') self._project_manager.add_project(project) self.assertEqual(self._project_manager.count_projects(), 1)
def set_project(self, github_name, github_user, jira_name, jira_url): self.project = Project(github_name, github_user, '', [jira_name], [], jira_url, '') self.set_extractor()