Skip to content

Commit

Permalink
Merge pull request #17 from bbean23/12-finish-merging-in-data-for-tests
Browse files Browse the repository at this point in the history
12 finish merging in data for tests. See email from Ben 3/12/2024.
  • Loading branch information
braden6521 authored Mar 12, 2024
2 parents fe35fee + 0926b5c commit c066a70
Show file tree
Hide file tree
Showing 113 changed files with 30 additions and 23 deletions.
5 changes: 5 additions & 0 deletions contrib/scripts/AbstractFileFingerprint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from abc import ABC
import dataclasses
import os


@dataclasses.dataclass()
Expand All @@ -9,6 +10,10 @@ class AbstractFileFingerprint(ABC):
name_ext: str
""" "name.ext" of the file. """

@property
def relpath_name_ext(self):
return os.path.join(self.relative_path, self.name_ext)

def eq_aff(self, other: 'AbstractFileFingerprint'):
if not isinstance(other, AbstractFileFingerprint):
return False
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 8 additions & 1 deletion opencsp/common/lib/tool/file_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,14 @@ def files_in_directory(input_dir, sort=True, files_only=False, recursive=False):
# Walk the directory and all subdirectories and assemble a list of files.
norm_input_dir = norm_path(input_dir)
for root, dirnames, file_names_exts in os.walk(norm_input_dir):
relative_path: str = root.replace(norm_input_dir, "").lstrip("./\\")
# remove the front of the path, in order to get the path relative to the input_dir
relative_path: str = root.replace(norm_input_dir, "")
# don't include any leading ./
if relative_path.startswith("./") or relative_path.startswith(".\\"):
relative_path = relative_path[2:]
# don't include any leading /
relative_path = relative_path.lstrip("\\/")

scanned_files += [
os.path.join(relative_path, file_name_ext)
for file_name_ext in file_names_exts
Expand Down
Empty file.
Empty file.
39 changes: 17 additions & 22 deletions opencsp/common/lib/tool/test/test_file_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,33 @@

class TestFileTools(unittest.TestCase):
def setUp(self) -> None:
self.data_dir = os.path.join(
orp.opencsp_code_dir(),
'common',
'lib',
'tool',
'test',
'data',
'input',
'file_tools',
)
self.out_dir = os.path.join(
orp.opencsp_code_dir(),
'common',
'lib',
'tool',
'test',
'data',
'output',
'file_tools',
)
path, _, _ = ft.path_components(__file__)
self.data_dir = os.path.join(path, "data", "input", "file_tools")
self.out_dir = os.path.join(path, "data", "output", "file_tools")

def tearDown(self) -> None:
pass

def test_files_in_directory(self):
files_name_ext = ft.files_in_directory(self.data_dir)
expected = ["a.a", "b.b", "d"]
expected = [".dotfile", "a.a", "b.b", "d"]
self.assertListEqual(expected, files_name_ext)

def test_files_in_directory_files_only(self):
files_name_ext = ft.files_in_directory(self.data_dir, files_only=True)
expected = ["a.a", "b.b"]
expected = [".dotfile", "a.a", "b.b"]
self.assertListEqual(expected, files_name_ext)

def test_files_in_directory_recursive(self):
files_name_ext = ft.files_in_directory(self.data_dir, recursive=True)
files_name_ext = [f.replace("\\", "/") for f in files_name_ext]
expected = [".dotfile", "a.a", "b.b", "d", "d/c.c", "d/e", "d/e/f.f"]
self.assertListEqual(expected, files_name_ext)

def test_files_in_directory_recursive_files_only(self):
files_name_ext = ft.files_in_directory(self.data_dir, recursive=True, files_only=True)
files_name_ext = [f.replace("\\", "/") for f in files_name_ext]
expected = [".dotfile", "a.a", "b.b", "d/c.c", "d/e/f.f"]
self.assertListEqual(expected, files_name_ext)

def test_files_in_directory_by_extension(self):
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added opencsp/test/data/sofast_measurements/camera.h5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c066a70

Please sign in to comment.