-
Notifications
You must be signed in to change notification settings - Fork 81
New tests added #87
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
Merged
Merged
New tests added #87
Changes from 47 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
06ae259
new tests added
timyr220 8708e58
changed the data
timyr220 fc2c0b2
updated unit test
timyr220 80e9aee
added rate limit tests
timyr220 7b78140
updated tests
timyr220 49b7e4d
firmware
timyr220 1758a31
added firmware tests
timyr220 55478e6
licence added
timyr220 2772434
licence added
timyr220 44a1ded
new tests have been added
timyr220 c783d0f
Fixed Thread by replacing target=self.__service_loop_func and then d…
timyr220 393bbcc
Fixed Thread by replacing target=self.__service_loop_func and then d…
timyr220 bda2d00
new tests added
timyr220 e233dcf
new tests added
timyr220 2a63323
new tests added
timyr220 5fe2c1c
minor modifications
timyr220 7d3046f
added firmware tests
timyr220 8bac088
added rate limit tests
timyr220 c6ba78b
added tests of tb_device_mqtt operation
timyr220 c432320
split message tests added
timyr220 ccd385f
added rpc reply tests
timyr220 abed2c8
added decoded message tests
timyr220 12d1781
added tb_gateway_mqtt tests
timyr220 bb9e2b3
added init_gateway tests
timyr220 f240f1b
added tests
timyr220 49c39d7
licence added and comments removed
timyr220 f63bc20
bug fixes
timyr220 1d0eb8d
add new tests
timyr220 baf987f
add new tests
timyr220 909de92
add new tests
timyr220 99e71a6
modified tests
timyr220 9a800ce
modified tests
timyr220 7f9e50f
modified tests
timyr220 46914ca
modified tests
timyr220 d212e36
modified tests
timyr220 85c4af8
modified tests
timyr220 dd542b3
modified tests
timyr220 2593264
Changed data
timyr220 d1af450
Removed blank lines
timyr220 10c55b5
Updated test
timyr220 04debc8
Updated logic
timyr220 38a5dcb
Updated logic
timyr220 932ff2a
Data changed and logic changed
timyr220 e9f2147
Updated data
timyr220 8820e75
New test added
timyr220 607f5cd
New test added
timyr220 ad084f2
changes removed
timyr220 c72e13d
Add TBDeviceMqttClient tests
timyr220 069c13b
Fix TBDeviceMqttClient tests
timyr220 5ec7ca6
Fix TBDeviceMqttClient tests
timyr220 94a8492
Fix TBDeviceMqttClient tests
timyr220 f79bbe6
Refactor TBDeviceMqttClient tests
timyr220 576aede
Refactor TBDeviceMqttClient tests
timyr220 9e7c480
Fix TBDeviceMqttClient tests
timyr220 c1a6603
Test fix
timyr220 0f2e2db
Function removed
timyr220 c4216ff
changed function name
timyr220 02b501b
New test added
timyr220 f0ae78b
fixed tests and replaced logic
timyr220 84462e7
changed data
timyr220 f6288b6
class removed
timyr220 962b57c
removed unnecessary classes and strings
timyr220 6ccbd88
back to the old version
timyr220 27e04fc
bug fixes
timyr220 1069459
resolve merge conflicts from GitHub
timyr220 0da9ba6
fix: force conflict resolution for tb_device_mqtt.py
timyr220 cdc74b1
Merge branch 'master' into master
timyr220 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # Copyright 2025. ThingsBoard | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import unittest | ||
| from tb_device_mqtt import TBDeviceMqttClient | ||
|
|
||
|
|
||
| class TestCountDataPointsInMessage(unittest.TestCase): | ||
| def test_simple_dict_no_device(self): | ||
| data = { | ||
| "ts": 123456789, | ||
| "values": { | ||
| "temp": 22.5, | ||
| "humidity": 55 | ||
| } | ||
| } | ||
| result = TBDeviceMqttClient._count_datapoints_in_message(data) | ||
| self.assertEqual(result, 2) | ||
|
|
||
| def test_list_of_dict_no_device(self): | ||
| data = [ | ||
| {"ts": 123456789, "values": {"temp": 22.5, "humidity": 55}}, | ||
| {"ts": 123456799, "values": {"light": 100, "pressure": 760}} | ||
| ] | ||
| result = TBDeviceMqttClient._count_datapoints_in_message(data) | ||
| self.assertEqual(result, 4) | ||
|
|
||
| def test_with_device_dict_inside(self): | ||
| data = { | ||
| "MyDevice": { | ||
| "ts": 123456789, | ||
| "values": {"temp": 22.5, "humidity": 55} | ||
| }, | ||
| "OtherKey": "some_value" | ||
| } | ||
| result = TBDeviceMqttClient._count_datapoints_in_message(data, device="MyDevice") | ||
| self.assertEqual(result, 2) | ||
|
|
||
| def test_with_device_list_inside(self): | ||
| data = { | ||
| "Sensor": [ | ||
| {"ts": 1, "values": {"v1": 10}}, | ||
| {"ts": 2, "values": {"v2": 20, "v3": 30}} | ||
| ] | ||
| } | ||
| result = TBDeviceMqttClient._count_datapoints_in_message(data, device="Sensor") | ||
| self.assertEqual(result, 3) | ||
|
|
||
| def test_empty_dict_no_device(self): | ||
| data = {} | ||
| result = TBDeviceMqttClient._count_datapoints_in_message(data) | ||
| self.assertEqual(result, 0) | ||
|
|
||
| def test_missing_device_key(self): | ||
|
|
||
| data = {"some_unrelated_key": 42} | ||
| result = TBDeviceMqttClient._count_datapoints_in_message(data, device="NotExistingDeviceKey") | ||
| self.assertEqual(result, 1) | ||
|
|
||
| def test_data_is_string_no_device(self): | ||
| data = "just a string" | ||
| result = TBDeviceMqttClient._count_datapoints_in_message(data) | ||
| self.assertEqual(result, 1) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.