Skip to content

Commit 0a3eeb8

Browse files
authored
Fix Block.parse to support CallBlock (#775)
1 parent ebb508d commit 0a3eeb8

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

slack/web/classes/blocks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def parse(cls, block: Union[dict, "Block"]) -> Optional["Block"]:
7878
return InputBlock(**block)
7979
elif type == FileBlock.type:
8080
return FileBlock(**block)
81+
elif type == CallBlock.type:
82+
return CallBlock(**block)
8183
elif type == HeaderBlock.type:
8284
return HeaderBlock(**block)
8385
else:

tests/web/classes/test_blocks.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def test_document_1(self):
6363
}
6464
}
6565
self.assertDictEqual(input, SectionBlock(**input).to_dict())
66+
self.assertDictEqual(input, Block.parse(input).to_dict())
6667

6768
def test_document_2(self):
6869
input = {
@@ -218,6 +219,7 @@ def test_document(self):
218219
"type": "divider"
219220
}
220221
self.assertDictEqual(input, DividerBlock(**input).to_dict())
222+
self.assertDictEqual(input, Block.parse(input).to_dict())
221223

222224
def test_json(self):
223225
self.assertDictEqual(
@@ -253,6 +255,7 @@ def test_document(self):
253255
"alt_text": "An incredibly cute kitten."
254256
}
255257
self.assertDictEqual(input, ImageBlock(**input).to_dict())
258+
self.assertDictEqual(input, Block.parse(input).to_dict())
256259

257260
def test_json(self):
258261
self.assertDictEqual(
@@ -337,6 +340,7 @@ def test_document_1(self):
337340
]
338341
}
339342
self.assertDictEqual(input, ActionsBlock(**input).to_dict())
343+
self.assertDictEqual(input, Block.parse(input).to_dict())
340344

341345
def test_document_2(self):
342346
input = {
@@ -444,6 +448,7 @@ def test_document(self):
444448
]
445449
}
446450
self.assertDictEqual(input, ContextBlock(**input).to_dict())
451+
self.assertDictEqual(input, Block.parse(input).to_dict())
447452

448453
def test_basic_json(self):
449454
self.elements = [
@@ -605,6 +610,7 @@ def test_document(self):
605610
]
606611
for input in blocks:
607612
self.assertDictEqual(input, InputBlock(**input).to_dict())
613+
self.assertDictEqual(input, Block.parse(input).to_dict())
608614

609615

610616
# ----------------------------------------------
@@ -619,6 +625,7 @@ def test_document(self):
619625
"source": "remote",
620626
}
621627
self.assertDictEqual(input, FileBlock(**input).to_dict())
628+
self.assertDictEqual(input, Block.parse(input).to_dict())
622629

623630
# ----------------------------------------------
624631
# Call
@@ -689,6 +696,7 @@ def test_with_real_payload(self):
689696
}
690697
}
691698
self.assertDictEqual(input, CallBlock(**input).to_dict())
699+
self.assertDictEqual(input, Block.parse(input).to_dict())
692700

693701

694702
# ----------------------------------------------

0 commit comments

Comments
 (0)