Skip to content

Commit

Permalink
Added tests for the --copy-all flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebagabones committed Dec 29, 2024
1 parent 3269230 commit 9009636
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 8 deletions.
41 changes: 34 additions & 7 deletions tests/__snapshots__/test_stuff.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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)
# ---
22 changes: 21 additions & 1 deletion tests/test_stuff.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import filecmp
import pytest
from pathlib import Path
import os
import shutil


def test_verbose(snapshot):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9009636

Please sign in to comment.