-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from grimmpp/feature-branch
tests improved
- Loading branch information
Showing
3 changed files
with
120 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,28 +1,27 @@ | ||
# Paramters for EEPs in Send Message Events | ||
## Not Supported EEPs | ||
* A5-09-0C | ||
* A5-38-08 | ||
# Paramters for EEPs in Send Message Events | ||
(This file was auto-generated by using [eltako14bus library](https://github.com/grimmpp/eltako14bus/blob/master/eltakobus/eep.py) in [version 0.0.49](https://pypi.org/project/eltako14bus/) from unit-test `TestSendMessageService` in file `./tests/test_send_message_service.py`). | ||
|
||
## Parameters for events: | ||
* A5-04-01: humidity, learn_button, temp_availability, temperature | ||
* A5-04-02: humidity, learn_button, temperature | ||
* A5-04-03: humidity, learn_button, telegram_type, temperature | ||
* A5-06-01: day_light, illumination, twilight | ||
* A5-07-01: learn_button, pir_status, pir_status_on, support_volrage_availability, support_voltage | ||
* A5-08-01: illumination, learn_button, occupancy_button, pir_status, supply_voltage, temperature | ||
* A5-10-06: current_temp, mode, stand_by, target_temp | ||
* A5-10-12: current_temperature, humidity, target_temperature | ||
* A5-12-01: data_type, divisor, learn_button, measurement_channel, meter_reading | ||
* A5-12-02: data_type, divisor, learn_button, measurement_channel, meter_reading | ||
* A5-12-03: data_type, divisor, learn_button, measurement_channel, meter_reading | ||
* A5-13-01: dawn_sensor, day_night, hemisphere, identifier, learn_button, rain_indication, sun_east, sun_south, sun_west, temperature, wind_speed | ||
* D5-00-01: contact, learn_button | ||
* F6-02-01: energy_bow, rocker_first_action, rocker_second_action, second_action | ||
* F6-02-02: energy_bow, rocker_first_action, rocker_second_action, second_action | ||
* F6-10-00: handle_position, movement | ||
* G5-3F-7F: direction, state, time | ||
* H5-3F-7F: command, learn_button, time | ||
* M5-38-08: state | ||
## Not Supported EEPs | ||
* `A5-09-0C` | ||
* `A5-38-08` | ||
|
||
## References: | ||
Implementation of EEPs can be found [eltako14bus library](https://github.com/grimmpp/eltako14bus/blob/master/eltakobus/eep.py). | ||
## Parameters for events | ||
* `A5-04-01`: humidity, learn_button, temp_availability, temperature | ||
* `A5-04-02`: humidity, learn_button, temperature | ||
* `A5-04-03`: humidity, learn_button, telegram_type, temperature | ||
* `A5-06-01`: day_light, illumination, twilight | ||
* `A5-07-01`: learn_button, pir_status, pir_status_on, support_volrage_availability, support_voltage | ||
* `A5-08-01`: illumination, learn_button, occupancy_button, pir_status, supply_voltage, temperature | ||
* `A5-10-06`: current_temp, mode, stand_by, target_temp | ||
* `A5-10-12`: current_temperature, humidity, target_temperature | ||
* `A5-12-01`: data_type, divisor, learn_button, measurement_channel, meter_reading | ||
* `A5-12-02`: data_type, divisor, learn_button, measurement_channel, meter_reading | ||
* `A5-12-03`: data_type, divisor, learn_button, measurement_channel, meter_reading | ||
* `A5-13-01`: dawn_sensor, day_night, hemisphere, identifier, learn_button, rain_indication, sun_east, sun_south, sun_west, temperature, wind_speed | ||
* `D5-00-01`: contact, learn_button | ||
* `F6-02-01`: energy_bow, rocker_first_action, rocker_second_action, second_action | ||
* `F6-02-02`: energy_bow, rocker_first_action, rocker_second_action, second_action | ||
* `F6-10-00`: handle_position, movement | ||
* `G5-3F-7F`: direction, state, time | ||
* `H5-3F-7F`: command, learn_button, time | ||
* `M5-38-08`: state |
This file contains 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,79 @@ | ||
import os | ||
import sys | ||
import unittest | ||
import json | ||
import site | ||
|
||
class MetadataTest(unittest.TestCase): | ||
|
||
def get_site_package_folder(self): | ||
for f in site.getsitepackages(): | ||
if 'site-packages' in f: | ||
return f | ||
|
||
def find_lib_folder(self, lib_name:str): | ||
dirs = [f for f in os.listdir(self.get_site_package_folder()) if f.startswith(lib_name.replace('-', '_')+'-')] | ||
if len(dirs) == 1: | ||
return os.path.join(self.get_site_package_folder(), dirs[0]) | ||
return None | ||
|
||
def get_installed_lib_version(self, lib_name:str): | ||
|
||
dir_name = self.find_lib_folder(lib_name) | ||
if dir_name: | ||
metadata_file = os.path.join(dir_name, 'METADATA') | ||
with open(metadata_file, 'r') as f: | ||
for l in f.readlines(): | ||
if l.startswith('Version: '): | ||
return l.replace('Version: ', '').strip() | ||
return None | ||
return None | ||
|
||
def get_version_of_installed_eltako14bus(self): | ||
return self.get_installed_lib_version('eltako14bus') | ||
|
||
def get_manifest(self): | ||
manifest_filename = os.path.join(os.getcwd(), 'custom_components', 'eltako', 'manifest.json') | ||
with open(manifest_filename, 'r') as f: | ||
return json.loads( f.read() ) | ||
|
||
def get_version_of_required_eltako14bus(self): | ||
manifest = self.get_manifest() | ||
|
||
for r in manifest['requirements']: | ||
if r.startswith('eltako14bus'): | ||
return r.split('==')[1].strip() | ||
return None | ||
|
||
def get_version_of_eltako_integration(self): | ||
return self.get_manifest()['version'] | ||
|
||
def test_check_all_installed_dependencies(self): | ||
manifest = self.get_manifest() | ||
|
||
for r in manifest['requirements']: | ||
if '==' in r: | ||
lib_name = r.split('==')[0].strip() | ||
required_version = r.split('==')[1].strip() | ||
installed_version = self.get_installed_lib_version(lib_name) | ||
|
||
# if this test fails install specified libraries in manifest.json | ||
self.assertEqual(required_version, installed_version) | ||
|
||
|
||
return None | ||
|
||
def test_eltako14bus_required_and_installed_is_the_same(self): | ||
installed = self.get_version_of_installed_eltako14bus() | ||
required = self.get_version_of_required_eltako14bus() | ||
|
||
self.assertIsNotNone(installed) | ||
self.assertIsNotNone(required) | ||
self.assertEqual(installed, required) | ||
|
||
def test_if_changes_are_documented(self): | ||
changes_filename = os.path.join(os.getcwd(), 'changes.md') | ||
with open(changes_filename, 'r', encoding="utf-8") as f: | ||
changes_text = f.read() | ||
|
||
self.assertTrue( f'## Version {self.get_version_of_eltako_integration()}' in changes_text ) |
This file contains 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