Skip to content

Commit deb944b

Browse files
committed
fix test
1 parent 9da39fe commit deb944b

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

application/tests/spreadsheet_test.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,22 @@ def test_prepare_spreadsheet(self) -> None:
109109
self.assertCountEqual(result, expected)
110110

111111
def test_read_spreadsheet_iso_numbers(self) -> None:
112-
url = "https://docs.google.com/spreadsheets/d/1eZOEYgts7d_-Dr-1oAbogPfzBLh6511b58pX3b59kvg" # CRE spreadsheet url
112+
url = "https://docs.google.com/spreadsheets/d/1ugU-FCIRLc5D_xpKOunelo26Wel3PTLnMKFdu7isZ3s" # Public iso test CRE spreadsheet url
113113
alias = "Test Spreadsheet"
114114
result = read_spreadsheet(url, alias, validate=False, parse_numbered_only=False)
115-
116-
# Assuming the spreadsheet has a column "ISO Number" with values "7.10" and "8.20"
117115
expected = [
118-
{"ISO Number": "7.10", "Name": "Example 1", "Value": 10},
119-
{"ISO Number": "8.20", "Name": "Example 2", "Value": 20},
116+
{
117+
"Standard 27001/2:2022": "Use of cryptography",
118+
"Standard 27001/2:2022 Section ID": "1.10",
119+
},
120+
{
121+
"Standard 27001/2:2022": "Privacy and protection of personal identifiable information (PII)",
122+
"Standard 27001/2:2022 Section ID": "10.10",
123+
},
124+
{
125+
"Standard 27001/2:2022": "Secure development life cycle",
126+
"Standard 27001/2:2022 Section ID": "1.31",
127+
},
120128
]
121129

122-
self.assertEqual(result["Sheet1"], expected)
130+
self.assertEqual(result["ISO Numericise Test"], expected)

application/utils/spreadsheet.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,19 @@ def read_spreadsheet(
5959
" will be processed by convention)" % wsh.title
6060
)
6161
records = wsh.get_all_records(
62-
head=1, numericise_ignore="all" # Added numericise_ignore parameter
62+
head=1,
63+
numericise_ignore=list(
64+
range(1, wsh.col_count)
65+
), # Added numericise_ignore parameter
6366
) # workaround because of https://github.com/burnash/gspread/issues/1007 # this will break if the column names are in any other line
6467
toyaml = yaml.safe_load(yaml.safe_dump(records))
6568
result[wsh.title] = toyaml
6669
elif not parse_numbered_only:
6770
records = wsh.get_all_records(
68-
head=1, numericise_ignore="all" # Added numericise_ignore parameter
71+
head=1,
72+
numericise_ignore=list(
73+
range(1, wsh.col_count)
74+
), # Added numericise_ignore parameter -- DO NOT make this 'all', gspread has a bug
6975
) # workaround because of https://github.com/burnash/gspread/issues/1007 # this will break if the column names are in any other line
7076
toyaml = yaml.safe_load(yaml.safe_dump(records))
7177
result[wsh.title] = toyaml

0 commit comments

Comments
 (0)