Skip to content

Commit

Permalink
Merge pull request #3322 from GSA-TTS/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jadudm authored Jan 31, 2024
2 parents e1f56d2 + b7b4b57 commit c5200d1
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 11 deletions.
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import os
import sys
import json
import argparse
import pprint
import logging
Expand Down Expand Up @@ -63,17 +62,8 @@ def handle(self, *args, **options): # noqa: C901
sys.exit()

audit_header = get_audit_header(options["dbkey"], year)
json_test_tables = []
for section, fun in sections_to_handlers.items():
(wb, api_json, _, filename) = generate_workbook(fun, audit_header, section)
(wb, _, filename) = generate_workbook(fun, audit_header, section)
if wb:
wb_path = os.path.join(outdir, filename)
wb.save(wb_path)
if api_json:
json_test_tables.append(api_json)

json_path = os.path.join(outdir, f'test-array-{options["dbkey"]}.json')
logger.info(f"Writing JSON to {json_path}")
with open(json_path, "w") as test_file:
jstr = json.dumps(json_test_tables, indent=2, sort_keys=True)
test_file.write(jstr)
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from django.conf import settings
from django.test import SimpleTestCase

from .workbooklib.corrective_action_plan import (
xform_add_placeholder_for_missing_references,
)


class TestXformAddPlaceholderForMissingCapText(SimpleTestCase):
class Findings:
def __init__(self, refnum):
self.FINDINGREFNUMS = refnum

class CapText:
def __init__(self, refnum, seqnum=None, text=None, chartstables=None):
self.FINDINGREFNUMS = refnum
self.SEQ_NUMBER = seqnum
self.TEXT = text
self.CHARTSTABLES = chartstables

def test_placeholder_addition_for_missing_references(self):
# Setup specific test data
mock_findings = [
self.Findings("ref1"),
self.Findings("ref2"),
]
mock_findings_texts = [
self.CapText("ref1", "1", "text1", "chart1"),
]

findings_texts = xform_add_placeholder_for_missing_references(
mock_findings, mock_findings_texts
)

self.assertEqual(
len(findings_texts), 2
) # Expecting two items in findings_texts
self.assertEqual(findings_texts[1].FINDINGREFNUMS, "ref2")
self.assertEqual(findings_texts[1].TEXT, settings.GSA_MIGRATION)
self.assertEqual(findings_texts[1].CHARTSTABLES, settings.GSA_MIGRATION)

def test_no_placeholder_addition_when_all_references_present(self):
# Setup specific test data
mock_findings = [
self.Findings("ref1"),
self.Findings("ref2"),
]
mock_findings_texts = [
self.CapText("ref1", "1", "text1", "chart1"),
self.CapText("ref2", "2", "text2", "chart2"),
]

findings_texts = xform_add_placeholder_for_missing_references(
mock_findings, mock_findings_texts
)

self.assertEqual(
len(findings_texts), 2
) # Expecting two items in findings_texts
self.assertEqual(findings_texts[0].FINDINGREFNUMS, "ref1")
self.assertEqual(findings_texts[1].FINDINGREFNUMS, "ref2")

0 comments on commit c5200d1

Please sign in to comment.