refining DictByBatchcodeTable2JsonConverterTest

This commit is contained in:
frankknoll
2023-01-26 23:31:34 +01:00
parent 0dc544f880
commit 56a903ebbe
2 changed files with 9 additions and 5 deletions

View File

@@ -17,9 +17,13 @@ class DictByBatchcodeTable2JsonConverter:
dictByBatchcodeTable dictByBatchcodeTable
.apply( .apply(
lambda row: { lambda row: {
"batchcodes": list(row.name), "batchcodes": DictByBatchcodeTable2JsonConverter._getNaNBatchcodes(row.name),
"histogram": row['SYMPTOM_COUNT_BY_VAX_LOT'] "histogram": row['SYMPTOM_COUNT_BY_VAX_LOT']
}, },
axis = 'columns') axis = 'columns')
.to_list() .to_list()
) )
@staticmethod
def _getNaNBatchcodes(batchcodes):
return [batchcode for batchcode in batchcodes if batchcode != 'nan']

View File

@@ -23,9 +23,9 @@ class DictByBatchcodeTable2JsonConverterTest(unittest.TestCase):
] ]
], ],
index = pd.MultiIndex.from_tuples( index = pd.MultiIndex.from_tuples(
names = ['VAX_LOT1', 'VAX_LOT2'], names = ['VAX_LOT1', 'VAX_LOT2', 'VAX_LOT3'],
tuples = [['1808982', 'EW0175'], tuples = [['1808982', 'EW0175', 'FD1921'],
['015M20A', '1808982']])) ['015M20A', '1808982', 'nan']]))
# When # When
jsonActual = DictByBatchcodeTable2JsonConverter.convertDictByBatchcodeTable2Json(dictByBatchcodeTable, '1808982') jsonActual = DictByBatchcodeTable2JsonConverter.convertDictByBatchcodeTable2Json(dictByBatchcodeTable, '1808982')
@@ -38,7 +38,7 @@ class DictByBatchcodeTable2JsonConverterTest(unittest.TestCase):
"batchcode": "1808982", "batchcode": "1808982",
"histograms": [ "histograms": [
{ {
"batchcodes": ["1808982", "EW0175"], "batchcodes": ["1808982", "EW0175", "FD1921"],
"histogram": { "histogram": {
"Blood pressure orthostatic abnormal": 5, "Blood pressure orthostatic abnormal": 5,
"Chest discomfort": 1 "Chest discomfort": 1