Skip to content

Fix exception caused by wrong parameter encoding to tlv.encode in camera.py#243

Merged
ikalchev merged 3 commits intoikalchev:devfrom
jdsnape:master
Apr 22, 2020
Merged

Fix exception caused by wrong parameter encoding to tlv.encode in camera.py#243
ikalchev merged 3 commits intoikalchev:devfrom
jdsnape:master

Conversation

@jdsnape
Copy link
Copy Markdown
Contributor

@jdsnape jdsnape commented Apr 18, 2020

Fixes #242

@bdraco
Copy link
Copy Markdown
Contributor

bdraco commented Apr 18, 2020

mock_driver = <tests.conftest.MockDriver object at 0x7f4ad197be10>

    def test_setup_endpoints(mock_driver):
        """Test that the SetupEndpoint response is computed correctly"""
        set_endpoint_req = ('ARCszGzBBWNFFY2pdLRQkAaRAxoBAQACDTE5Mi4xNjguMS4xMTQDAjPFBAKs1gQ'
                            'lAhDYlmCkyTBZQfxqFS3OnxVOAw4bQZm5NuoQjyanlqWA0QEBAAUlAhAKRPSRVa'
                            'qGeNmESTIojxNiAw78WkjTLtGv0waWnLo9gQEBAA==')
    
        set_endpoint_res = ('ARCszGzBBWNFFY2pdLRQkAaRAgEAAxoBAQACDTE5Mi4xNjguMS4yMjYDAjPFBAK'
                            's1gQlAQEAAhDYlmCkyTBZQfxqFS3OnxVOAw4bQZm5NuoQjyanlqWA0QUlAQEAAh'
                            'AKRPSRVaqGeNmESTIojxNiAw78WkjTLtGv0waWnLo9gQYBAQcBAQ==')
    
        acc = camera.Camera(_OPTIONS, mock_driver, 'Camera')
        setup_endpoints = acc.get_service('CameraRTPStreamManagement')\
                             .get_characteristic('SetupEndpoints')
        setup_endpoints.client_update_value(set_endpoint_req)
    
>       assert setup_endpoints.get_value() == set_endpoint_res
E       AssertionError: assert 'ARCszGzBBWNF...uAAcEFqcpAA==' == 'ARCszGzBBWNF...9gQYBAQcBAQ=='
E         Skipping 161 identical leading characters in diff, use -v to show
E         - waWnLo9gQYBAQcBAQ==
E         + waWnLo9gQYEE+BuAAcEFqcpAA==

tests/test_camera.py:79: AssertionError

Looks like the test is getting further along

@bdraco
Copy link
Copy Markdown
Contributor

bdraco commented Apr 18, 2020

diff --git a/tests/test_camera.py b/tests/test_camera.py
index f3424d7..3fec258 100644
--- a/tests/test_camera.py
+++ b/tests/test_camera.py
@@ -76,7 +76,11 @@ def test_setup_endpoints(mock_driver):
                          .get_characteristic('SetupEndpoints')
     setup_endpoints.client_update_value(set_endpoint_req)
 
-    assert setup_endpoints.get_value() == set_endpoint_res
+    end_point_value = setup_endpoints.get_value()
+
+    # We have random bytes in the endpoint so only the
+    # first 161 chars will match
+    assert end_point_value[:161] == set_endpoint_res[:161]
 
 
 def test_set_selected_stream_start_stop(mock_driver):

@jdsnape Something like this should fix the test

@jdsnape
Copy link
Copy Markdown
Contributor Author

jdsnape commented Apr 19, 2020

@bdraco Have updated the camera test - it all passes now:

===================================== test session starts ======================================
platform linux -- Python 3.7.3, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /home/jdsnape/HAP-python, inifile: setup.cfg
plugins: cov-2.8.1, timeout-1.3.4
collected 3 items

tests/test_camera.py ...                                                                 [100%]

====================================== 3 passed in 0.03s =======================================

@bdraco
Copy link
Copy Markdown
Contributor

bdraco commented Apr 19, 2020

Testing passing for me as well. I'm giving this a spin now

@bdraco
Copy link
Copy Markdown
Contributor

bdraco commented Apr 19, 2020

Seems ok now

@ikalchev ikalchev merged commit c19a67f into ikalchev:dev Apr 22, 2020
@bdraco
Copy link
Copy Markdown
Contributor

bdraco commented Apr 29, 2020

@ikalchev Would you be able to do a release to resolve this later this week? It appears we are close to having Home Assistant HomeKit Camera support land in home-assistant/core#32527 (comment)

@ikalchev
Copy link
Copy Markdown
Owner

Will do tomorrow, hope it’s ok!

@ikalchev
Copy link
Copy Markdown
Owner

ikalchev commented May 1, 2020

2.8.3 is now available in pip/github.

Thank you all!
Ivan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to encode TLV value for camera

3 participants