Skip to content

Commit

Permalink
adjusted constants and added to main
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Wolff authored and Will Wolff committed Nov 28, 2023
1 parent a830402 commit bd09029
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 111 deletions.
89 changes: 1 addition & 88 deletions cellveyor/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,6 @@ class Cellveyor:
Website=":link: GitHub: https://github.com/GatorEducator/cellveyor",
)

# checks constant
@dataclass(frozen=True)
class Checks:
"""Define the Checks dataclass for constant(s)."""

Check_Cellveyor: str
Check_Code: str
Check_Count: str
Check_Confidence: int
Check_Spreadsheet: str
Check_Id: str
Checks_Label: str
Check_Name: str
Check_Cell: str


checks = Checks(
Check_Cellveyor="cellveyor",
Check_Code="code",
Check_Count="count",
Check_Confidence=80,
Check_Spreadsheet="spreadsheet",
Check_Id="id",
Checks_Label="checks",
Check_Name="name",
Check_Cell="cell",
)

# filesystem constant
@dataclass(frozen=True)
class Filesystem:
Expand All @@ -73,22 +45,11 @@ class Filesystem:
Current_Directory: str
Dash: str
Dot: str
Main_Configuration_File: str
Main_Checks_File: str
Current_Report_Name: str
Cell_Name: str
Results_Extension: str


filesystem = Filesystem(
Current_Directory=".",
Dash="-",
Dot=".",
Main_Configuration_File="config.yml",
Main_Checks_File="checks.yml",
Current_Report_Name="cellveyor-report",
Cell_Name="cell-report",
Results_Extension="",
)

# humanreadable constant
Expand All @@ -102,66 +63,18 @@ class Humanreadable:

humanreadable = Humanreadable(Yes="Yes", No="No")


# markers constant
@dataclass(frozen=True)
class Markers:
"""Define the Markers dataclass for constant(s)."""

Comma_Space: str
Empty_Bytes: bytes
Empty_String: str
Ellipse: str
Forward_Slash: str
Dot: str
Hidden: str
Indent: str
Newline: str
Non_Zero_Exit: int
Nothing: str
Single_Quote: str
Slice_One: int
Space: str
Tab: str
Underscore: str
Xml: str
Zero: int
Indent = str
Zero_Exit: int


markers = Markers(

Comma_Space=", ",
Empty_Bytes=b"",
Empty_String="",
Ellipse="...",
Forward_Slash="/",
Dot=".",
Hidden=".",
Indent=" ",
Newline="\n",
Non_Zero_Exit=1,
Nothing="",
Single_Quote="'",
Slice_One=1,
Space=" ",
Tab="\t",
Underscore="_",
Xml="xml",
Zero=0,
Zero_Exit=0,
)


# output constant
@dataclass(frozen=True)
class Output:
"""Define the Output dataclass for constant(s)."""

Test_Start: str


output = Output(

Test_Start=":sparkles: Start to run test suite for the specified program",
)
4 changes: 3 additions & 1 deletion cellveyor/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""🚚 Cellveyor is a conveyor for the cells in spreadsheets."""

import sys
from pathlib import Path
from typing import Dict, List

Expand Down Expand Up @@ -28,7 +29,7 @@ def display_reports(reports_dict: Dict[str, str]) -> None:
sh = gc.open_by_url(current_report)
# display the report inside of a rich panel, using
# a markdown-based formatter for the report's contents
console.print(Panel(Markdown(current_report), title="Report", expand=False))
console.print(f"{constants.markers.Indent} {Panel(Markdown(current_report), title='Report', expand=False)}")
console.print()
console.print(sh.sheet1.get())

Expand Down Expand Up @@ -112,6 +113,7 @@ def transport( # noqa: PLR0913
spreadsheet_file, spreadsheet_directory
):
console.print(":person_shrugging: Unable to access file and/or directory")
sys.exit(constants.markers.Non_Zero_Exit)
# access all of the sheets inside of the valid spreadsheet file
fully_qualified_spreadsheet_file = spreadsheet_directory / spreadsheet_file
console.print(f":delivery_truck: Accessing: {fully_qualified_spreadsheet_file}")
Expand Down
24 changes: 2 additions & 22 deletions tests/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,9 @@
def test_filesystem_constants():
"""Confirm default values of constants."""
assert constants.filesystem.Current_Directory == "."
assert constants.filesystem.Main_Configuration_File == "config.yml"
assert constants.humanreadable.Yes == "Yes"
assert constants.humanreadable.No == "No"


@given(
directory=strategies.text(),
configfile=strategies.text(),
checksfile=strategies.text(),
extra=strategies.text(),
yes=strategies.text(),
no=strategies.text(),
)
@pytest.mark.fuzz
def test_fuzz_init(directory, configfile, checksfile, extra, yes, no): # noqa: PLR0913
"""Use Hypothesis to confirm that initial value is set correctly."""
fs = constants.Filesystem(
directory, configfile, checksfile, extra, extra, extra, extra, extra, extra
)
assert fs.Current_Directory == directory
hr = constants.Humanreadable(yes, no)
assert hr.Yes == yes
assert hr.No == no


@given(
fs=strategies.builds(constants.Filesystem),
hr=strategies.builds(constants.Humanreadable),
Expand All @@ -49,3 +27,5 @@ def test_fuzz_immutable(fs, hr):
hr.Yes = "YES"
with pytest.raises(FrozenInstanceError):
hr.No = "NO"


0 comments on commit bd09029

Please sign in to comment.