def test_changeLocalRepo(self): repo.changeLocalRepo( "C:\\Users\\den_t\\Documents\\GitHub\\team25-Project\\deliverable5" ) self.assertEqual( repo.getLocalRepo(), "C:\\Users\\den_t\\Documents\\GitHub\\team25-Project\\deliverable5", "Did not correctly change the repo")
def commitCommand(): '''(None) -> None Checks if localRepoPath is a valid path. If it is, syncs the local repository, copies all the extracted XMLs from Changed_Systems into the local repository, and pushes changes to the remote. Changes the last update date to current date ''' localRepoPath = repoTools.getLocalRepo() if (os.path.isdir(localRepoPath) == False ): #file is not right, print message and pass if case print( "Problem in path. Please set the path of local repository using 'repo' command" ) else: #pull from remote to make sure local is up to date git.pull_repo(localRepoPath) #print clean up report in a text file stdout = sys.stdout #keep a handle on the real standard output if (os.path.isfile('cleanUpReport.txt')): with open('cleanUpReport.txt', 'w') as f: f.write("") sys.stdout = open('cleanUpReport.txt', 'w', encoding='utf-8') try: cleanUp.cleanUp() except: print("Fail to run clean up script") #reset stdout sys.stdout = stdout #go through changed_systems and copy files to local repo source_dir = os.path.join(os.getcwd(), "Changed_Systems") print("Copying files...") for filename in glob.glob(os.path.join(source_dir, '*.*')): try: shutil.copy(filename, localRepoPath) except: print("Couldn't copy " + filename + " to " + localRepoPath + ". Please close all files and try again") #push changes from local to remote git.push_all(localRepoPath) #change updated date today = str(datetime.date.today()) fname = "last_commit_date.txt" with open(fname, 'w') as f: f.write(today) print("Changes successfully made. Last updated date is now " + today)
man.main() elif (command[0:7] == "extract"): success = True try: if (command[7:].find(" -l") > -1): list_updated.main() if (extract_ExoPlanet.get() != -1): extract_ExoPlanet.parse() if (extract_NASA.get() != -1): extract_NASA.parse() except: print( "Extraction from external sources failed. Try closing all opened CSV files and try again" ) success = False localRepoPath = repoTools.getLocalRepo() if (localRepoPath == "" ): #file is not right, print message and pass if case print( "Problem in path. Please set the path of local repository using 'repo' command" ) success = False extractedXmlsPath = os.path.join(os.getcwd(), 'extracted', 'Extracted_XMLs') #clear change_systems of old updates xmltools.ensure_empty_dir(os.path.join(os.getcwd(), "Changed_Systems")) #if not success, let's save time from going through anything if (success): for filename in glob.iglob(os.path.join(extractedXmlsPath, "*.xml")): #performance improv: check matchedSystems file to see if there is a previous match of this planetary system
def test_changeLocalRepoEmpty(self): repo.changeLocalRepo("") self.assertEqual(repo.getLocalRepo(), "", "Repo should now be empty")
def test_getLocalRepo(self): self.assertEqual( repo.getLocalRepo(), "C:\\Users\\den_t\\Documents\\GitHub\\team25-Project\\deliverable5\\Application", "Wrong path returned")