Repository: slackapi/python-slackclient
Pull request #775 (2020-08-06 16:06:56)

Correct Block.parse(dict) to support CallBlock
###  Summary

While reviewing #768 , I found that `CallBlock` is not yet supported in `Block.parse(dict)` method. The block class was introduced by #704. I missed changing the class method in the PR.

### Requirements (place an `x` in each `[ ]`)

* [x] I've read and understood the [Contributing Guidelines](https://github.com/slackapi/python-slackclient/blob/master/.github/contributing.md) and have done my best effort to follow them.
* [x] I've read and agree to the [Code of Conduct](https://slackhq.github.io/code-of-conduct).

codecov[bot]: # [Codecov](https://codecov.io/gh/slackapi/python-slackclient/pull/775?src=pr&el=h1) Report
> Merging [#775](https://codecov.io/gh/slackapi/python-slackclient/pull/775?src=pr&el=desc) into [main](https://codecov.io/gh/slackapi/python-slackclient/commit/042bb05edbada181e3bc29b12c5d95ffb75588a0&el=desc) will **increase** coverage by `0.06%`.
> The diff coverage is `50.00%`.

[![Impacted file tree graph](https://codecov.io/gh/slackapi/python-slackclient/pull/775/graphs/tree.svg?width=650&height=150&src=pr&token=F0O7meYmtD)](https://codecov.io/gh/slackapi/python-slackclient/pull/775?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##             main     #775      +/-   ##
==========================================
+ Coverage   87.25%   87.31%   +0.06%     
==========================================
  Files          30       30              
  Lines        3585     3587       +2     
  Branches      316      317       +1     
==========================================
+ Hits         3128     3132       +4     
+ Misses        325      323       -2     
  Partials      132      132              
```


| [Impacted Files](https://codecov.io/gh/slackapi/python-slackclient/pull/775?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [slack/web/classes/blocks.py](https://codecov.io/gh/slackapi/python-slackclient/pull/775/diff?src=pr&el=tree#diff-c2xhY2svd2ViL2NsYXNzZXMvYmxvY2tzLnB5) | `93.15% <50.00%> (+1.13%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/slackapi/python-slackclient/pull/775?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/slackapi/python-slackclient/pull/775?src=pr&el=footer). Last update [042bb05...235826a](https://codecov.io/gh/slackapi/python-slackclient/pull/775?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/slack/web/classes/blocks.py b/slack/web/classes/blocks.py
index 9001ee0..f995e3c 100644
--- a/slack/web/classes/blocks.py
+++ b/slack/web/classes/blocks.py
@@ -78,6 +78,8 @@ class Block(JsonObject):
                     return InputBlock(**block)
                 elif type == FileBlock.type:
                     return FileBlock(**block)
+                elif type == CallBlock.type:
+                    return CallBlock(**block)
                 elif type == HeaderBlock.type:
                     return HeaderBlock(**block)
                 else:


Test patch:
diff --git a/tests/web/classes/test_blocks.py b/tests/web/classes/test_blocks.py
index da56ba8..a748943 100644
--- a/tests/web/classes/test_blocks.py
+++ b/tests/web/classes/test_blocks.py
@@ -63,6 +63,7 @@ class SectionBlockTests(unittest.TestCase):
             }
         }
         self.assertDictEqual(input, SectionBlock(**input).to_dict())
+        self.assertDictEqual(input, Block.parse(input).to_dict())
 
     def test_document_2(self):
         input = {
@@ -218,6 +219,7 @@ class DividerBlockTests(unittest.TestCase):
             "type": "divider"
         }
         self.assertDictEqual(input, DividerBlock(**input).to_dict())
+        self.assertDictEqual(input, Block.parse(input).to_dict())
 
     def test_json(self):
         self.assertDictEqual(
@@ -253,6 +255,7 @@ class ImageBlockTests(unittest.TestCase):
             "alt_text": "An incredibly cute kitten."
         }
         self.assertDictEqual(input, ImageBlock(**input).to_dict())
+        self.assertDictEqual(input, Block.parse(input).to_dict())
 
     def test_json(self):
         self.assertDictEqual(
@@ -337,6 +340,7 @@ class ActionsBlockTests(unittest.TestCase):
             ]
         }
         self.assertDictEqual(input, ActionsBlock(**input).to_dict())
+        self.assertDictEqual(input, Block.parse(input).to_dict())
 
     def test_document_2(self):
         input = {
@@ -444,6 +448,7 @@ class ContextBlockTests(unittest.TestCase):
             ]
         }
         self.assertDictEqual(input, ContextBlock(**input).to_dict())
+        self.assertDictEqual(input, Block.parse(input).to_dict())
 
     def test_basic_json(self):
         self.elements = [
@@ -605,6 +610,7 @@ class InputBlockTests(unittest.TestCase):
         ]
         for input in blocks:
             self.assertDictEqual(input, InputBlock(**input).to_dict())
+            self.assertDictEqual(input, Block.parse(input).to_dict())
 
 
 # ----------------------------------------------
@@ -619,6 +625,7 @@ class FileBlockTests(unittest.TestCase):
             "source": "remote",
         }
         self.assertDictEqual(input, FileBlock(**input).to_dict())
+        self.assertDictEqual(input, Block.parse(input).to_dict())
 
 # ----------------------------------------------
 # Call
@@ -689,6 +696,7 @@ class CallBlockTests(unittest.TestCase):
             }
         }
         self.assertDictEqual(input, CallBlock(**input).to_dict())
+        self.assertDictEqual(input, Block.parse(input).to_dict())
 
 
 # ----------------------------------------------