Skip to content

Commit

Permalink
import from export format
Browse files Browse the repository at this point in the history
  • Loading branch information
northdpole committed Aug 3, 2024
1 parent 84caf20 commit c01b90a
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 301 deletions.
14 changes: 3 additions & 11 deletions application/defs/cre_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
from application.defs import cre_exceptions


class ExportFormat(
Enum
): # TODO: this can likely be replaced with a method that iterates over an object's vars and formats headers to
class ExportFormat: # TODO: this can likely be replaced with a method that iterates over an object's vars and formats headers to
# <doctype>:<name>:<varname>
separator = "|"
section = "name"
Expand All @@ -24,14 +22,8 @@ class ExportFormat(
tooltype = "ToolType"
# sectionID = "SectionID"

@classmethod
def attributes():
return [
"name",
"hyperlink",
"description",
"id",
]
def __str__(self):
return str(self.value)

@staticmethod
def get_doctype(header: str) -> Optional["Credoctypes"]:
Expand Down
29 changes: 8 additions & 21 deletions application/tests/spreadsheet_parsers_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json
from pprint import pprint
import unittest
from application.tests.utils import data_gen
from application.defs import cre_defs as defs
Expand All @@ -8,30 +10,15 @@


class TestParsers(unittest.TestCase):

def test_parse_export_format(self) -> None:
"""Given
* CRE "C1" -> Standard "S1" section "SE1"
* CRE "C2" -> CRE "C3" linktype contains
* CRE "C3" -> "C2" (linktype is part of), Standard "S3" section "SE3"
* CRE "C5" -> Standard "S1" section "SE1" subsection "SBE1"
* CRE "C5" -> Standard "S1" section "SE1" subsection "SBE11"
* CRE "C6" -> Standard "S1" section "SE11", Standard "S2" section "SE22", CRE "C7"(linktype contains) , CRE "C8" (linktype contains)
* Standard "SL"
* Standard "SL2" -> Standard "SLL"
# * CRE "C9"
Expect:
9 CRES
9 standards
appropriate links among them based on the arrows above
"""

input_data, expected = data_gen.export_format_data()
result = parse_export_format(input_data)
cres, standards = parse_export_format(input_data)
self.maxDiff = None
for key, val in result.items():
# self.assertDictEqual(expected[key].todict(), val.todict())
expected[key].links = []
val.links = []
self.assertDictEqual(val.todict(), expected[key].todict())

self.assertListEqual(list(cres), list(expected[defs.Credoctypes.CRE]))
self.assertListEqual(list(expected[defs.Credoctypes.Standard]), list(standards))

def test_parse_hierarchical_export_format(self) -> None:
# TODO(northdpole): add a tags linking test
Expand Down
Loading

0 comments on commit c01b90a

Please sign in to comment.