diff --git a/tests/__snapshots__/test_stuff.ambr b/tests/__snapshots__/test_stuff.ambr index ebb8676..c3f284d 100644 --- a/tests/__snapshots__/test_stuff.ambr +++ b/tests/__snapshots__/test_stuff.ambr @@ -18,8 +18,35 @@ True, ]) # --- +# name: test_copyAllFiles + list([ + 'blankDir/', + ' index.html', + ' myRack.html', + ' bonescrawlhome.html', + ' bonesrunhome.html', + ' bonesboundhome.html', + ' report.html', + ' template.html', + ' bonescallhome.html', + ' 404.html', + ' robots.txt', + ' emacsFiles.html', + ' Power7.html', + ' contact.html', + ' static/', + ' theDreadedTexFile.tex', + ' styles.css', + ' favicon.ico', + ' theIdioticTimeDistributionOfAReport.pdf', + ' js/', + ' preloadImages.js', + ' minimal-theme-switcher.js', + ' anotherThemeChanger.js', + ]) +# --- # name: test_dir - Namespace(dir=True, inputFile=['dir'], templates_dir=None, output='.', no_warnings=False, verbose=False) + Namespace(dir=True, inputFile=['dir'], templates_dir=None, output='.', no_warnings=False, verbose=False, copy_all=False) # --- # name: test_getIncludeFileText tuple( @@ -30,7 +57,7 @@ ) # --- # name: test_infile - Namespace(dir=False, inputFile=['inputFile'], templates_dir=None, output='.', no_warnings=False, verbose=False) + Namespace(dir=False, inputFile=['inputFile'], templates_dir=None, output='.', no_warnings=False, verbose=False, copy_all=False) # --- # name: test_lookForInclude tuple( @@ -111,17 +138,17 @@ ) # --- # name: test_templates_dir - Namespace(dir=True, inputFile=['dir'], templates_dir=['templates'], output='.', no_warnings=False, verbose=False) + Namespace(dir=True, inputFile=['dir'], templates_dir=['templates'], output='.', no_warnings=False, verbose=False, copy_all=False) # --- # name: test_templates_infile - Namespace(dir=False, inputFile=['inputFile'], templates_dir=['template'], output='.', no_warnings=False, verbose=False) + Namespace(dir=False, inputFile=['inputFile'], templates_dir=['template'], output='.', no_warnings=False, verbose=False, copy_all=False) # --- # name: test_templates_output_dir - Namespace(dir=True, inputFile=['dir'], templates_dir=['templates'], output=['output'], no_warnings=False, verbose=False) + Namespace(dir=True, inputFile=['dir'], templates_dir=['templates'], output=['output'], no_warnings=False, verbose=False, copy_all=False) # --- # name: test_templates_output_infile - Namespace(dir=False, inputFile=['inputFile'], templates_dir=['template'], output=['output'], no_warnings=False, verbose=False) + Namespace(dir=False, inputFile=['inputFile'], templates_dir=['template'], output=['output'], no_warnings=False, verbose=False, copy_all=False) # --- # name: test_verbose - Namespace(dir=False, inputFile=['inputFile'], templates_dir=None, output='.', no_warnings=False, verbose=True) + Namespace(dir=False, inputFile=['inputFile'], templates_dir=None, output='.', no_warnings=False, verbose=True, copy_all=False) # --- diff --git a/tests/test_stuff.py b/tests/test_stuff.py index 782bb0a..572b2d8 100644 --- a/tests/test_stuff.py +++ b/tests/test_stuff.py @@ -6,6 +6,8 @@ import filecmp import pytest from pathlib import Path +import os +import shutil def test_verbose(snapshot): @@ -90,7 +92,25 @@ def test_checkFiles(snapshot): arrayOfMatchesOfNot.append(filecmp.cmp(sitesFile, knownGoodFile, shallow=False)) assert arrayOfMatchesOfNot == snapshot -# def test_checkFiles(snapshot): + +def test_copyAllFiles(snapshot): + if(os.path.exists("tests/testFolder/blankDir")): + if os.path.isfile("tests/testFolder/blankDir"): + os.remove("tests/testFolder/blankDir") + else: + shutil.rmtree("tests/testFolder/blankDir") + ssri.copyAllFiles("tests/testFolder/staging","tests/testFolder/blankDir") + outputCheck = [] + for root, dirs, files in os.walk("tests/testFolder/blankDir"): # Gratefully borrowed from here https://stackoverflow.com/questions/9727673/list-directory-tree-structure-in-python + level = root.replace("tests/testFolder/blankDir", '').count(os.sep) # As dir structure is important to track if it changes in this test so formatting the output makes sense + indent = ' ' * 4 * (level) + outputCheck.append(('{}{}/'.format(indent, os.path.basename(root)))) + subindent = ' ' * 4 * (level + 1) + for f in files: + outputCheck.append(('{}{}'.format(subindent, f))) + shutil.rmtree("tests/testFolder/blankDir") + assert outputCheck == snapshot + # inputFiles = ssri.getListOfFilesToSearchDir("tests/testFolder/staging", ["tests/testFolder/sites"], True, False) # knownGoodFiles = ssri.getListOfFilesToSearchDir("tests/testFolder/staging", ["tests/testFolder/sites"], True, False) # This is me being lazy and using getListOfFiles to get an array for the known good copy of sites # fileCreatedCounter = 0