Skip to content

Commit

Permalink
WIP: integration tests
Browse files Browse the repository at this point in the history
original tests have been moved into the correct location.

Code updates have been made as a result of basic test output.

NB. this commit will be deleted and replaced with better test data.
  • Loading branch information
ross-spencer committed May 26, 2024
1 parent e9dc281 commit 11d97bc
Show file tree
Hide file tree
Showing 7 changed files with 693 additions and 110 deletions.
1 change: 1 addition & 0 deletions requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ pre-commit==3.7.1
pip-upgrader==1.4.15
pylint==3.1.0
pytest==8.2.0
pytest-mock==3.14.0
setuptools==69.5.1
tox==4.15.0
42 changes: 25 additions & 17 deletions src/anz_rosetta_csv/RosettaCSVGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,23 @@


class RosettaCSVGenerator:
"""Rosetta CSV Generator Object."""

config = None
droidcsv = None
exportsheet = None
rosettaschema = None
rosettasections = None
prov = None
rosettacsvdict = None

def __init__(
self,
droidcsv=False,
exportsheet=False,
rosettaschema=False,
configfile=False,
provenance=False,
droidcsv=None,
exportsheet=None,
rosettaschema=None,
configfile=None,
provenance=None,
):
if not configfile:
logger.error("a configuration file hasn't been provided")
Expand Down Expand Up @@ -125,14 +135,12 @@ def compare_filenames_as_titles(self, droidrow, listcontroltitle):
pass
else:
# Fail but don't exit desirable(?) so as to see all errors at once
sys.stderr.write(
"Filename comparison has failed. Check list control: "
+ listcontroltitle.encode("utf-8")
+ " vs. DROID export: "
+ droid_filename_title.encode("utf-8")
+ "\n"
logger.error(
"Filename comparison has failed. Check list control: '%s' vs. droid export %s",
listcontroltitle,
droid_filename_title,
)

return False
return True

# NOTE: itemtitle is title from Archway List Control...
Expand Down Expand Up @@ -232,10 +240,10 @@ def csvstringoutput(self, csvlist):
'"Object Type","SIP Title"', '"Object Type","Title (DC)"'
)

sys.stdout.write(csvrows)

for dupe in self.duplicateitemsaddedset:
sys.stderr.write("Duplicates to monitor: " + dupe + "\n")
logger.info("duplicates to monitor: %s", dupe)

return csvrows

def handleprovenanceexceptions(
self, PROVENANCE_FIELD, sectionrow, field, csvindex, rnumber
Expand Down Expand Up @@ -393,7 +401,7 @@ def createrosettacsv(self):
fields.append(itemrow)
csvindex = CSVINDEXSTARTPOS

self.csvstringoutput(fields)
return self.csvstringoutput(fields)

# TODO: unit tests for this...
def listduplicates(self):
Expand Down Expand Up @@ -442,4 +450,4 @@ def export2rosettacsv(self):
self.prov = False

self.duplicates = self.listduplicates()
self.createrosettacsv()
return self.createrosettacsv()
85 changes: 0 additions & 85 deletions src/anz_rosetta_csv/RosettaCSVGeneratorTests.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/anz_rosetta_csv/anz_rosetta_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def exportsheetRosettamapping(
csvgen = RosettaCSVGenerator(
droidcsv, exportsheet, rosettaschema, configfile, provenance
)
csvgen.export2rosettacsv()
print(csvgen.export2rosettacsv())


def main():
Expand Down
9 changes: 6 additions & 3 deletions src/anz_rosetta_csv/rosettacsvsectionsclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,27 @@


class RosettaCSVSections:
sections = []
"""Rosetta CSV sections handler object."""

sections = None
config = None

def __init__(self, configfile):
logging.info("reading app config from '%s'", configfile)
self.config = ConfigParser.RawConfigParser()
self.config.read(configfile)

# Configure via CFG to avoid users having to edit code
sections = []
if self.config.has_option("rosetta csv fields", "CSVSECTIONS"):
sections = self.config.get("rosetta csv fields", "CSVSECTIONS").split(",")

self.sect = []
self.sections = []
for section in sections:
if self.config.has_option("rosetta csv fields", section):
sectiondict = {}
fieldlist = self.config.get("rosetta csv fields", section)
sectiondict[section] = fieldlist.split(",")

self.sections.append(sectiondict)
else:
sys.stdout.write("Error reading fields from config file, exiting...")
Expand Down
Loading

0 comments on commit 11d97bc

Please sign in to comment.