Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types for update_stats #657

Merged
merged 10 commits into from
May 9, 2024
Merged

Conversation

kimdv
Copy link
Contributor

@kimdv kimdv commented May 5, 2024

It will be part of home-assistant/core#116737

This will add typed info for update_stats.WAN.monitors

JSON example from a UDM SE

{
  "data": [
    {
      "uptime_stats": {
        "WAN": {
          "monitors": [
            {
              "availability": 100.0,
              "latency_average": 5,
              "target": "www.microsoft.com",
              "type": "icmp"
            },
            {
              "availability": 100.0,
              "latency_average": 7,
              "target": "google.com",
              "type": "icmp"
            },
            {
              "availability": 100.0,
              "latency_average": 5,
              "target": "1.1.1.1",
              "type": "icmp"
            }
          ]
        },
        "WAN2": {
          "monitors": [
            {
              "availability": 0.0,
              "target": "www.microsoft.com",
              "type": "icmp"
            },
            {
              "availability": 0.0,
              "target": "google.com",
              "type": "icmp"
            },
            {
              "availability": 0.0,
              "target": "1.1.1.1",
              "type": "icmp"
            }
          ]
        }
      }
    }
  ]
}

aiounifi/models/device.py Outdated Show resolved Hide resolved
aiounifi/models/device.py Outdated Show resolved Hide resolved
@Kane610
Copy link
Owner

Kane610 commented May 5, 2024

I have more time to look tomorrow. I was also planning on doing this for you but good you got here first :)

@kimdv
Copy link
Contributor Author

kimdv commented May 5, 2024

I have more time to look tomorrow. I was also planning on doing this for you but good you got here first :)

Awesome! :D

Copy link
Owner

@Kane610 Kane610 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also extend one of the device tests for this.

aiounifi/models/device.py Outdated Show resolved Hide resolved
aiounifi/models/device.py Outdated Show resolved Hide resolved
aiounifi/models/device.py Outdated Show resolved Hide resolved
aiounifi/models/device.py Outdated Show resolved Hide resolved
aiounifi/models/device.py Outdated Show resolved Hide resolved
Copy link
Owner

@Kane610 Kane610 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there!

aiounifi/models/device.py Outdated Show resolved Hide resolved
tests/test_devices.py Outdated Show resolved Hide resolved
@kimdv
Copy link
Contributor Author

kimdv commented May 7, 2024

@Kane610
I get this test error

FAILED tests/test_devices.py::test_device[device_payload5-reference_data5] - AssertionError: assert None == {'WAN': {'monitors': [{'availability': 100.0, 'latency_average': 5, 'target': 'www.microsoft.com', 'type': 'icmp'}, {'...ilability': 0.0, 'target': 'google.com', 'type': 'icmp'}, {'availability': 0.0, 'target': '1.1.1.1', 'type': 'icmp'}]}}

Not sure why?
Is it because that we expect an object that isn't there?
In this case I must be the uptime_stats

@kimdv
Copy link
Contributor Author

kimdv commented May 7, 2024

@Kane610 I get this test error

FAILED tests/test_devices.py::test_device[device_payload5-reference_data5] - AssertionError: assert None == {'WAN': {'monitors': [{'availability': 100.0, 'latency_average': 5, 'target': 'www.microsoft.com', 'type': 'icmp'}, {'...ilability': 0.0, 'target': 'google.com', 'type': 'icmp'}, {'availability': 0.0, 'target': '1.1.1.1', 'type': 'icmp'}]}}

Not sure why? Is it because that we expect an object that isn't there? In this case I must be the uptime_stats

I needed to add in fixtures.py.

But removing the data in 13772ac don't make it fail?

@kimdv kimdv requested a review from Kane610 May 7, 2024 19:47
Copy link
Owner

@Kane610 Kane610 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the test to use a better fixture representable to the where the data can be found for real and this is ready

tests/test_devices.py Outdated Show resolved Hide resolved
@Kane610
Copy link
Owner

Kane610 commented May 8, 2024

@Kane610 I get this test error

FAILED tests/test_devices.py::test_device[device_payload5-reference_data5] - AssertionError: assert None == {'WAN': {'monitors': [{'availability': 100.0, 'latency_average': 5, 'target': 'www.microsoft.com', 'type': 'icmp'}, {'...ilability': 0.0, 'target': 'google.com', 'type': 'icmp'}, {'availability': 0.0, 'target': '1.1.1.1', 'type': 'icmp'}]}}

Not sure why? Is it because that we expect an object that isn't there? In this case I must be the uptime_stats

I needed to add in fixtures.py.

But removing the data in 13772ac don't make it fail?

Removing the data doesn't do anything you remove the data to check against the existence of the data so when you remove it there is no comparison done for the update stats

@kimdv kimdv force-pushed the kimdv/add-uptime-stats branch from 78a7140 to ee373e9 Compare May 9, 2024 12:36
@kimdv kimdv requested a review from Kane610 May 9, 2024 12:41
Copy link
Owner

@Kane610 Kane610 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

@Kane610 Kane610 merged commit 403e357 into Kane610:master May 9, 2024
1 check passed
@Kane610
Copy link
Owner

Kane610 commented May 9, 2024

I will do a release shortly

@kimdv kimdv deleted the kimdv/add-uptime-stats branch May 9, 2024 18:57
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.

2 participants