python-eigen-ingenuity 0.5.17__py3-none-any.whl → 0.5.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. eigeningenuity/__init__.py +2 -1
  2. eigeningenuity/core/__init__.py +9 -3
  3. eigeningenuity/historianmulti.py +7 -0
  4. local-tests/__init__.py +4 -0
  5. local-tests/common.py +45 -0
  6. local-tests/config.py +29 -0
  7. local-tests/demo.py +81 -0
  8. local-tests/historian/__init__.py +1 -0
  9. local-tests/historian/test_getCurrentDataPoints.py +70 -0
  10. local-tests/historian/test_getInterpolatedPoints.py +80 -0
  11. local-tests/historian/test_getInterpolatedRange.py +99 -0
  12. local-tests/historian/test_getMetaData.py +47 -0
  13. local-tests/historian/test_getRawDataPoints.py +92 -0
  14. local-tests/historian/test_listDataTags.py +51 -0
  15. local-tests/historian/test_writePoints.py +57 -0
  16. local-tests/historianmulti/__init__.py +1 -0
  17. local-tests/historianmulti/common_multi.py +46 -0
  18. local-tests/historianmulti/test_getClosestRawPoint.py +74 -0
  19. local-tests/historianmulti/test_getCurrentDataPoints.py +53 -0
  20. local-tests/historianmulti/test_getInterpolatedPoints.py +69 -0
  21. local-tests/historianmulti/test_getInterpolatedRange.py +85 -0
  22. local-tests/historianmulti/test_getMetaData.py +51 -0
  23. local-tests/historianmulti/test_getRawDatapoints.py +85 -0
  24. local-tests/historianmulti/test_listDataTags.py +59 -0
  25. local-tests/historianmulti/test_tagManagement.py +88 -0
  26. local-tests/historianmulti/test_writePoints.py +70 -0
  27. local-tests/run_tests.py +461 -0
  28. modelbuilder/src/configmanager.py +4 -1
  29. modelbuilder/src/connectors/boltconnector.py +1 -1
  30. modelbuilder/src/connectors/httpsconnector.py +1 -1
  31. modelbuilder/src/csvcontentsmanager.py +3 -3
  32. modelbuilder/src/filemanager.py +2 -2
  33. modelbuilder/src/processors/nodefileprocessor.py +2 -2
  34. {python_eigen_ingenuity-0.5.17.dist-info → python_eigen_ingenuity-0.5.18.dist-info}/METADATA +1 -1
  35. python_eigen_ingenuity-0.5.18.dist-info/RECORD +93 -0
  36. {python_eigen_ingenuity-0.5.17.dist-info → python_eigen_ingenuity-0.5.18.dist-info}/top_level.txt +2 -0
  37. regressiontests/__init__.py +1 -0
  38. regressiontests/eigeningenuity/__init__.py +1 -0
  39. regressiontests/eigeningenuity/common.py +137 -0
  40. regressiontests/eigeningenuity/common_multi.py +133 -0
  41. regressiontests/eigeningenuity/historian/__init__.py +1 -0
  42. regressiontests/eigeningenuity/historian/common.py +113 -0
  43. regressiontests/eigeningenuity/historian/test_getCurrentDataPoints.py +163 -0
  44. regressiontests/eigeningenuity/historian/test_getInterpolatedPoints.py +175 -0
  45. regressiontests/eigeningenuity/historian/test_getInterpolatedRange.py +203 -0
  46. regressiontests/eigeningenuity/historian/test_getMetaData.py +102 -0
  47. regressiontests/eigeningenuity/historian/test_getRawDataPoints.py +214 -0
  48. regressiontests/eigeningenuity/historian/test_listDataTags.py +48 -0
  49. regressiontests/eigeningenuity/historian/test_writePoints.py +54 -0
  50. regressiontests/eigeningenuity/historian-multi/__init__.py +1 -0
  51. regressiontests/eigeningenuity/historian-multi/common_multi.py +143 -0
  52. regressiontests/eigeningenuity/historian-multi/test_getClosestRawPoint.py +123 -0
  53. regressiontests/eigeningenuity/historian-multi/test_getCurrentDataPoints.py +117 -0
  54. regressiontests/eigeningenuity/historian-multi/test_getInterpolatedPoints.py +124 -0
  55. regressiontests/eigeningenuity/historian-multi/test_getInterpolatedRange.py +139 -0
  56. regressiontests/eigeningenuity/historian-multi/test_getMetaData.py +48 -0
  57. regressiontests/eigeningenuity/historian-multi/test_getRawDatapoints.py +153 -0
  58. regressiontests/eigeningenuity/historian-multi/test_listDataTags.py +56 -0
  59. regressiontests/eigeningenuity/historian-multi/test_tagManagement.py +129 -0
  60. regressiontests/eigeningenuity/historian-multi/test_writePoints.py +67 -0
  61. python_eigen_ingenuity-0.5.17.dist-info/RECORD +0 -45
  62. {python_eigen_ingenuity-0.5.17.dist-info → python_eigen_ingenuity-0.5.18.dist-info}/WHEEL +0 -0
  63. {python_eigen_ingenuity-0.5.17.dist-info → python_eigen_ingenuity-0.5.18.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,57 @@
1
+ """
2
+ Test writePoints function from historian module
3
+ """
4
+ import sys
5
+ import os
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
7
+
8
+ from tests.common import BaseHistorianTest
9
+ import unittest
10
+ from datetime import datetime
11
+
12
+
13
+ class TestWritePoints(BaseHistorianTest):
14
+ """Test cases for writePoints function"""
15
+
16
+ def setUp(self):
17
+ """Extended setup for write tests"""
18
+ super().setUp()
19
+ self.test_write_tag = "eigen_manual_input/TEST_WRITE_TAG"
20
+
21
+ def test_write_single_point(self):
22
+ """Test writing a single data point"""
23
+ point_data = {"value": 42.5, "timestamp": datetime.now(), "status": "OK"}
24
+
25
+ try:
26
+ result = self.historian.writePoints(self.test_write_tag, [point_data])
27
+ self.assertIsInstance(result, bool)
28
+ except Exception as e:
29
+ # Write operations may fail if permissions are not available
30
+ self.skipTest(f"Write operation not permitted: {e}")
31
+
32
+ def test_write_multiple_points(self):
33
+ """Test writing multiple data points"""
34
+ points_data = [
35
+ {"value": 42.5, "timestamp": datetime.now(), "status": "OK"},
36
+ {"value": 43.0, "timestamp": datetime.now(), "status": "OK"}
37
+ ]
38
+
39
+ try:
40
+ result = self.historian.writePoints(self.test_write_tag, points_data)
41
+ self.assertIsInstance(result, bool)
42
+ except Exception as e:
43
+ self.skipTest(f"Write operation not permitted: {e}")
44
+
45
+ def test_write_point_with_bad_status(self):
46
+ """Test writing a point with bad status"""
47
+ point_data = {"value": 42.5, "timestamp": datetime.now(), "status": "BAD"}
48
+
49
+ try:
50
+ result = self.historian.writePoints(self.test_write_tag, [point_data])
51
+ self.assertIsInstance(result, bool)
52
+ except Exception as e:
53
+ self.skipTest(f"Write operation not permitted: {e}")
54
+
55
+
56
+ if __name__ == '__main__':
57
+ unittest.main()
@@ -0,0 +1 @@
1
+ """HistorianMulti module tests"""
@@ -0,0 +1,46 @@
1
+ """
2
+ Common test configuration and utilities for historianmulti tests
3
+ """
4
+ import sys
5
+ import os
6
+ import unittest
7
+ import warnings
8
+ from datetime import datetime
9
+
10
+ # Add the parent directory to the Python path to import local version
11
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
12
+
13
+ # Import local version
14
+ from eigeningenuity import EigenServer, disable_azure_auth
15
+ from eigeningenuity.historianmulti import get_historian_multi
16
+ from urllib3.exceptions import InsecureRequestWarning
17
+
18
+ # Disable warnings and Azure auth for testing
19
+ warnings.simplefilter('ignore', InsecureRequestWarning)
20
+ disable_azure_auth()
21
+
22
+ class BaseHistorianMultiTest(unittest.TestCase):
23
+ """Base class for historian multi tests with common setup"""
24
+
25
+ def setUp(self):
26
+ """Common setup for all historian multi tests"""
27
+ self.server = EigenServer("demo-dev.eigen.co")
28
+ self.historian_name = "Demo-influxdb"
29
+ self.historian_multi = get_historian_multi(self.server, self.historian_name)
30
+ self.test_datetime = datetime(2024, 5, 1, 2, 0, 0)
31
+ self.test_tags = ["DEMO_02TI301.PV", "DEMO_02TI201.PV"]
32
+ self.test_tags_with_historian = [f"{self.historian_name}/DEMO_02TI301.PV", f"{self.historian_name}/DEMO_02TI201.PV"]
33
+ self.calc_tag = "calc/ADD(1,2)"
34
+
35
+ def assertValidDataPoint(self, data_point):
36
+ """Assert that a data point has valid structure"""
37
+ self.assertIsInstance(data_point, dict)
38
+ self.assertIn('value', data_point)
39
+ self.assertIn('timestamp', data_point)
40
+ self.assertIn('status', data_point)
41
+
42
+ def assertValidDataPointList(self, data_points):
43
+ """Assert that a list of data points is valid"""
44
+ self.assertIsInstance(data_points, list)
45
+ for dp in data_points:
46
+ self.assertValidDataPoint(dp)
@@ -0,0 +1,74 @@
1
+ """
2
+ Test getClosestRawPoint function from historianmulti module
3
+ """
4
+ import sys
5
+ import os
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
7
+
8
+ from tests.historianmulti.common_multi import BaseHistorianMultiTest
9
+ import unittest
10
+
11
+
12
+ class TestGetClosestRawPointMulti(BaseHistorianMultiTest):
13
+ """Test cases for getClosestRawPoint function in historianmulti"""
14
+
15
+ def test_get_closest_raw_single_tag_single_timestamp(self):
16
+ """Test getting closest raw point for single tag at single timestamp"""
17
+ result = self.historian_multi.getClosestRawPoint(
18
+ self.test_tags[0],
19
+ self.test_datetime,
20
+ before_or_after="AFTER"
21
+ )
22
+ self.assertIsInstance(result, (dict, list))
23
+
24
+ def test_get_closest_raw_single_tag_multiple_timestamps(self):
25
+ """Test getting closest raw points for single tag at multiple timestamps"""
26
+ timestamps = [self.test_datetime, 1718180259]
27
+ result = self.historian_multi.getClosestRawPoint(
28
+ self.test_tags[0],
29
+ timestamps,
30
+ before_or_after="AFTER"
31
+ )
32
+ self.assertIsInstance(result, (dict, list))
33
+
34
+ def test_get_closest_raw_multiple_tags_single_timestamp(self):
35
+ """Test getting closest raw points for multiple tags at single timestamp"""
36
+ result = self.historian_multi.getClosestRawPoint(
37
+ self.test_tags,
38
+ self.test_datetime,
39
+ before_or_after="AFTER"
40
+ )
41
+ self.assertIsInstance(result, (dict, list))
42
+
43
+ def test_get_closest_raw_multiple_tags_multiple_timestamps(self):
44
+ """Test getting closest raw points for multiple tags at multiple timestamps"""
45
+ timestamps = [self.test_datetime, 1718180259]
46
+ result = self.historian_multi.getClosestRawPoint(
47
+ self.test_tags,
48
+ timestamps,
49
+ before_or_after="AFTER"
50
+ )
51
+ self.assertIsInstance(result, (dict, list))
52
+
53
+ def test_get_closest_raw_before(self):
54
+ """Test getting closest raw point before timestamp"""
55
+ result = self.historian_multi.getClosestRawPoint(
56
+ self.test_tags[0],
57
+ self.test_datetime,
58
+ before_or_after="BEFORE"
59
+ )
60
+ self.assertIsInstance(result, (dict, list))
61
+
62
+ def test_get_closest_raw_with_epoch_timestamp(self):
63
+ """Test getting closest raw point with epoch timestamp"""
64
+ epoch_time = 1714525200 # May 1, 2024 2:00:00 AM
65
+ result = self.historian_multi.getClosestRawPoint(
66
+ self.test_tags[0],
67
+ epoch_time,
68
+ before_or_after="AFTER"
69
+ )
70
+ self.assertIsInstance(result, (dict, list))
71
+
72
+
73
+ if __name__ == '__main__':
74
+ unittest.main()
@@ -0,0 +1,53 @@
1
+ """
2
+ Test getCurrentDataPoints function from historianmulti module
3
+ """
4
+ import sys
5
+ import os
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
7
+
8
+ from tests.historianmulti.common_multi import BaseHistorianMultiTest
9
+ import unittest
10
+
11
+
12
+ class TestGetCurrentDataPointsMulti(BaseHistorianMultiTest):
13
+ """Test cases for getCurrentDataPoints function in historianmulti"""
14
+
15
+ def test_get_current_single_tag_default(self):
16
+ """Test getting current data point for single tag with default output"""
17
+ result = self.historian_multi.getCurrentDataPoints(self.test_tags[0])
18
+ self.assertIsInstance(result, (dict, list))
19
+
20
+ def test_get_current_single_tag_json(self):
21
+ """Test getting current data point for single tag with json output"""
22
+ result = self.historian_multi.getCurrentDataPoints(self.test_tags[0], output="json")
23
+ self.assertIsInstance(result, (dict, list))
24
+
25
+ def test_get_current_multiple_tags(self):
26
+ """Test getting current data points for multiple tags"""
27
+ result = self.historian_multi.getCurrentDataPoints(self.test_tags)
28
+ self.assertIsInstance(result, (dict, list))
29
+
30
+ def test_get_current_with_historian_prefix(self):
31
+ """Test getting current data point with historian prefix"""
32
+ result = self.historian_multi.getCurrentDataPoints(self.test_tags_with_historian)
33
+ self.assertIsInstance(result, (dict, list))
34
+
35
+ def test_get_current_calc_tag(self):
36
+ """Test getting current data point for calculation tag"""
37
+ result = self.historian_multi.getCurrentDataPoints(self.calc_tag)
38
+ self.assertIsInstance(result, (dict, list))
39
+
40
+ def test_get_current_mixed_tags(self):
41
+ """Test getting current data points with mixed historian sources"""
42
+ mixed_tags = [self.test_tags[0], self.calc_tag]
43
+ result = self.historian_multi.getCurrentDataPoints(mixed_tags)
44
+ self.assertIsInstance(result, (dict, list))
45
+
46
+ def test_get_current_empty_tag_list(self):
47
+ """Test behavior with empty tag list"""
48
+ result = self.historian_multi.getCurrentDataPoints([])
49
+ self.assertIsInstance(result, (dict, list))
50
+
51
+
52
+ if __name__ == '__main__':
53
+ unittest.main()
@@ -0,0 +1,69 @@
1
+ """
2
+ Test getInterpolatedPoints function from historianmulti module
3
+ """
4
+ import sys
5
+ import os
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
7
+
8
+ from tests.historianmulti.common_multi import BaseHistorianMultiTest
9
+ import unittest
10
+
11
+
12
+ class TestGetInterpolatedPointsMulti(BaseHistorianMultiTest):
13
+ """Test cases for getInterpolatedPoints function in historianmulti"""
14
+
15
+ def test_get_interpolated_single_tag_single_timestamp(self):
16
+ """Test getting interpolated point for single tag at single timestamp"""
17
+ result = self.historian_multi.getInterpolatedPoints(
18
+ self.test_tags[0],
19
+ self.test_datetime
20
+ )
21
+ self.assertIsInstance(result, (dict, list))
22
+
23
+ def test_get_interpolated_single_tag_multiple_timestamps(self):
24
+ """Test getting interpolated points for single tag at multiple timestamps"""
25
+ timestamps = [self.test_datetime, 1718180259]
26
+ result = self.historian_multi.getInterpolatedPoints(
27
+ self.test_tags[0],
28
+ timestamps
29
+ )
30
+ self.assertIsInstance(result, (dict, list))
31
+
32
+ def test_get_interpolated_multiple_tags_single_timestamp(self):
33
+ """Test getting interpolated points for multiple tags at single timestamp"""
34
+ result = self.historian_multi.getInterpolatedPoints(
35
+ self.test_tags,
36
+ self.test_datetime
37
+ )
38
+ self.assertIsInstance(result, (dict, list))
39
+
40
+ def test_get_interpolated_multiple_tags_multiple_timestamps(self):
41
+ """Test getting interpolated points for multiple tags at multiple timestamps"""
42
+ timestamps = [self.test_datetime, 1718180259]
43
+ result = self.historian_multi.getInterpolatedPoints(
44
+ self.test_tags,
45
+ timestamps
46
+ )
47
+ self.assertIsInstance(result, (dict, list))
48
+
49
+ def test_get_interpolated_with_json_output(self):
50
+ """Test getting interpolated points with json output format"""
51
+ result = self.historian_multi.getInterpolatedPoints(
52
+ self.test_tags[0],
53
+ self.test_datetime,
54
+ output="json"
55
+ )
56
+ self.assertIsInstance(result, (dict, list))
57
+
58
+ def test_get_interpolated_with_epoch_timestamp(self):
59
+ """Test getting interpolated points with epoch timestamp"""
60
+ epoch_time = 1714525200 # May 1, 2024 2:00:00 AM
61
+ result = self.historian_multi.getInterpolatedPoints(
62
+ self.test_tags[0],
63
+ epoch_time
64
+ )
65
+ self.assertIsInstance(result, (dict, list))
66
+
67
+
68
+ if __name__ == '__main__':
69
+ unittest.main()
@@ -0,0 +1,85 @@
1
+ """
2
+ Test getInterpolatedRange function from historianmulti module
3
+ """
4
+ import sys
5
+ import os
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
7
+
8
+ from tests.historianmulti.common_multi import BaseHistorianMultiTest
9
+ import unittest
10
+ from datetime import datetime, timedelta
11
+
12
+
13
+ class TestGetInterpolatedRangeMulti(BaseHistorianMultiTest):
14
+ """Test cases for getInterpolatedRange function in historianmulti"""
15
+
16
+ def test_get_interpolated_range_single_tag(self):
17
+ """Test getting interpolated range for single tag"""
18
+ end_time = datetime.now()
19
+ start_time = end_time - timedelta(hours=24)
20
+
21
+ result = self.historian_multi.getInterpolatedRange(
22
+ self.test_tags[0],
23
+ start_time,
24
+ end_time,
25
+ num_points=10
26
+ )
27
+ self.assertIsInstance(result, (dict, list))
28
+
29
+ def test_get_interpolated_range_multiple_tags(self):
30
+ """Test getting interpolated range for multiple tags"""
31
+ end_time = datetime.now()
32
+ start_time = end_time - timedelta(hours=24)
33
+ num_points = 5
34
+
35
+ result = self.historian_multi.getInterpolatedRange(
36
+ self.test_tags,
37
+ start_time,
38
+ end_time,
39
+ num_points=num_points
40
+ )
41
+ self.assertIsInstance(result, (dict, list))
42
+
43
+ def test_get_interpolated_range_with_json_output(self):
44
+ """Test getting interpolated range with json output"""
45
+ end_time = datetime.now()
46
+ start_time = end_time - timedelta(hours=24)
47
+
48
+ result = self.historian_multi.getInterpolatedRange(
49
+ self.test_tags[0],
50
+ start_time,
51
+ end_time,
52
+ num_points=5,
53
+ output="json"
54
+ )
55
+ self.assertIsInstance(result, (dict, list))
56
+
57
+ def test_get_interpolated_range_with_epoch_times(self):
58
+ """Test getting interpolated range with epoch timestamps"""
59
+ end_time = 1714525200 + 3600 # May 1, 2024 3:00:00 AM
60
+ start_time = 1714525200 # May 1, 2024 2:00:00 AM
61
+
62
+ result = self.historian_multi.getInterpolatedRange(
63
+ self.test_tags[0],
64
+ start_time,
65
+ end_time,
66
+ num_points=3
67
+ )
68
+ self.assertIsInstance(result, (dict, list))
69
+
70
+ def test_get_interpolated_range_single_point(self):
71
+ """Test getting interpolated range with single point"""
72
+ end_time = datetime.now()
73
+ start_time = end_time - timedelta(hours=24)
74
+
75
+ result = self.historian_multi.getInterpolatedRange(
76
+ self.test_tags[0],
77
+ start_time,
78
+ end_time,
79
+ num_points=1
80
+ )
81
+ self.assertIsInstance(result, (dict, list))
82
+
83
+
84
+ if __name__ == '__main__':
85
+ unittest.main()
@@ -0,0 +1,51 @@
1
+ """
2
+ Test getMetaData function from historianmulti module
3
+ """
4
+ import sys
5
+ import os
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
7
+
8
+ from tests.historianmulti.common_multi import BaseHistorianMultiTest
9
+ import unittest
10
+
11
+
12
+ class TestGetMetaDataMulti(BaseHistorianMultiTest):
13
+ """Test cases for getMetaData function in historianmulti"""
14
+
15
+ def test_get_metadata_default(self):
16
+ """Test getting metadata with default parameters"""
17
+ result = self.historian_multi.getMetaData()
18
+ self.assertIsInstance(result, (dict, list))
19
+
20
+ def test_get_metadata_with_historian(self):
21
+ """Test getting metadata with specific historian"""
22
+ result = self.historian_multi.getMetaData(historian=self.historian_name)
23
+ self.assertIsInstance(result, (dict, list))
24
+
25
+ def test_get_metadata_with_match_pattern(self):
26
+ """Test getting metadata with match pattern"""
27
+ result = self.historian_multi.getMetaData(
28
+ historian=self.historian_name,
29
+ match="TI"
30
+ )
31
+ self.assertIsInstance(result, (dict, list))
32
+
33
+ def test_get_metadata_with_limit(self):
34
+ """Test getting metadata with limit"""
35
+ result = self.historian_multi.getMetaData(
36
+ historian=self.historian_name,
37
+ limit=5
38
+ )
39
+ self.assertIsInstance(result, (dict, list))
40
+
41
+ def test_get_metadata_specific_pattern(self):
42
+ """Test getting metadata with specific pattern"""
43
+ result = self.historian_multi.getMetaData(
44
+ historian=self.historian_name,
45
+ match="*301*"
46
+ )
47
+ self.assertIsInstance(result, (dict, list))
48
+
49
+
50
+ if __name__ == '__main__':
51
+ unittest.main()
@@ -0,0 +1,85 @@
1
+ """
2
+ Test getRawDatapoints function from historianmulti module
3
+ """
4
+ import sys
5
+ import os
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
7
+
8
+ from tests.historianmulti.common_multi import BaseHistorianMultiTest
9
+ import unittest
10
+ from datetime import datetime, timedelta
11
+
12
+
13
+ class TestGetRawDataPointsMulti(BaseHistorianMultiTest):
14
+ """Test cases for getRawDatapoints function in historianmulti"""
15
+
16
+ def test_get_raw_single_tag(self):
17
+ """Test getting raw data points for single tag"""
18
+ end_time = datetime.now()
19
+ start_time = end_time - timedelta(hours=24)
20
+
21
+ result = self.historian_multi.getRawDatapoints(
22
+ self.test_tags[0],
23
+ start_time,
24
+ end_time,
25
+ maxpoints=10
26
+ )
27
+ self.assertIsInstance(result, (dict, list))
28
+
29
+ def test_get_raw_multiple_tags(self):
30
+ """Test getting raw data points for multiple tags"""
31
+ end_time = datetime.now()
32
+ start_time = end_time - timedelta(hours=24)
33
+
34
+ result = self.historian_multi.getRawDatapoints(
35
+ self.test_tags,
36
+ start_time,
37
+ end_time,
38
+ maxpoints=10
39
+ )
40
+ self.assertIsInstance(result, (dict, list))
41
+
42
+ def test_get_raw_with_json_output(self):
43
+ """Test getting raw data points with json output"""
44
+ end_time = datetime.now()
45
+ start_time = end_time - timedelta(hours=24)
46
+
47
+ result = self.historian_multi.getRawDatapoints(
48
+ self.test_tags[0],
49
+ start_time,
50
+ end_time,
51
+ maxpoints=10,
52
+ output="json"
53
+ )
54
+ self.assertIsInstance(result, (dict, list))
55
+
56
+ def test_get_raw_with_epoch_times(self):
57
+ """Test getting raw data points with epoch timestamps"""
58
+ end_time = 1714525200 + 3600 # May 1, 2024 3:00:00 AM
59
+ start_time = 1714525200 # May 1, 2024 2:00:00 AM
60
+
61
+ result = self.historian_multi.getRawDatapoints(
62
+ self.test_tags[0],
63
+ start_time,
64
+ end_time,
65
+ maxpoints=10
66
+ )
67
+ self.assertIsInstance(result, (dict, list))
68
+
69
+ def test_get_raw_with_limit(self):
70
+ """Test getting raw data points with maxpoints limit"""
71
+ end_time = datetime.now()
72
+ start_time = end_time - timedelta(days=1)
73
+ max_points = 5
74
+
75
+ result = self.historian_multi.getRawDatapoints(
76
+ self.test_tags[0],
77
+ start_time,
78
+ end_time,
79
+ maxpoints=max_points
80
+ )
81
+ self.assertIsInstance(result, (dict, list))
82
+
83
+
84
+ if __name__ == '__main__':
85
+ unittest.main()
@@ -0,0 +1,59 @@
1
+ """
2
+ Test listDataTags function from historianmulti module
3
+ """
4
+ import sys
5
+ import os
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
7
+
8
+ from tests.historianmulti.common_multi import BaseHistorianMultiTest
9
+ import unittest
10
+
11
+
12
+ class TestListDataTagsMulti(BaseHistorianMultiTest):
13
+ """Test cases for listDataTags function in historianmulti"""
14
+
15
+ def test_list_data_tags_default(self):
16
+ """Test listing data tags with default parameters"""
17
+ result = self.historian_multi.listDataTags()
18
+ self.assertIsInstance(result, (dict, list))
19
+
20
+ def test_list_data_tags_with_historian(self):
21
+ """Test listing data tags with specific historian"""
22
+ result = self.historian_multi.listDataTags(historian=self.historian_name)
23
+ self.assertIsInstance(result, (dict, list))
24
+
25
+ def test_list_data_tags_with_match_pattern(self):
26
+ """Test listing data tags with match pattern"""
27
+ result = self.historian_multi.listDataTags(
28
+ historian=self.historian_name,
29
+ match="TI*"
30
+ )
31
+ self.assertIsInstance(result, (dict, list))
32
+
33
+ def test_list_data_tags_with_limit(self):
34
+ """Test listing data tags with limit"""
35
+ result = self.historian_multi.listDataTags(
36
+ historian=self.historian_name,
37
+ limit=5
38
+ )
39
+ self.assertIsInstance(result, (dict, list))
40
+
41
+ def test_list_data_tags_specific_pattern(self):
42
+ """Test listing data tags with specific pattern"""
43
+ result = self.historian_multi.listDataTags(
44
+ historian=self.historian_name,
45
+ match="*301*"
46
+ )
47
+ self.assertIsInstance(result, (dict, list))
48
+
49
+ def test_list_data_tags_no_matches(self):
50
+ """Test listing data tags with pattern that has no matches"""
51
+ result = self.historian_multi.listDataTags(
52
+ historian=self.historian_name,
53
+ match="NONEXISTENT_PATTERN_12345"
54
+ )
55
+ self.assertIsInstance(result, (dict, list))
56
+
57
+
58
+ if __name__ == '__main__':
59
+ unittest.main()
@@ -0,0 +1,88 @@
1
+ """
2
+ Test tag management functions from historianmulti module
3
+ """
4
+ import sys
5
+ import os
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
7
+
8
+ from tests.historianmulti.common_multi import BaseHistorianMultiTest
9
+ import unittest
10
+ from datetime import datetime
11
+
12
+
13
+ class TestTagManagementMulti(BaseHistorianMultiTest):
14
+ """Test cases for tag management functions in historianmulti"""
15
+
16
+ def setUp(self):
17
+ """Extended setup for tag management tests"""
18
+ super().setUp()
19
+ self.test_tag = "eigen_manual_input/TEST_TAG_MANAGEMENT"
20
+
21
+ def test_create_tag(self):
22
+ """Test creating a new tag"""
23
+ try:
24
+ result = self.historian_multi.createTag(
25
+ self.test_tag,
26
+ description="Test tag for unit tests",
27
+ units="test_unit",
28
+ stepped=False,
29
+ update_existing=True
30
+ )
31
+ self.assertIsInstance(result, (bool, dict, list))
32
+ except Exception as e:
33
+ self.skipTest(f"Create tag operation not permitted: {e}")
34
+
35
+ def test_update_tag(self):
36
+ """Test updating an existing tag"""
37
+ try:
38
+ result = self.historian_multi.updateTag(
39
+ self.test_tag,
40
+ description="Updated test tag for unit tests",
41
+ units="updated_unit",
42
+ stepped=True,
43
+ create_missing=True
44
+ )
45
+ self.assertIsInstance(result, (bool, dict, list))
46
+ except Exception as e:
47
+ self.skipTest(f"Update tag operation not permitted: {e}")
48
+
49
+ def test_create_and_populate_tag(self):
50
+ """Test creating and populating a tag in one operation"""
51
+ point_data = {"value": 123.45, "timestamp": datetime.now(), "status": "OK"}
52
+
53
+ try:
54
+ result = self.historian_multi.createAndPopulateTag(
55
+ self.test_tag,
56
+ point_data,
57
+ description="Test tag created and populated",
58
+ units="test_unit",
59
+ stepped=False,
60
+ update_existing=True
61
+ )
62
+ self.assertIsInstance(result, (bool, dict, list))
63
+ except Exception as e:
64
+ self.skipTest(f"Create and populate tag operation not permitted: {e}")
65
+
66
+ def test_create_and_populate_tag_with_list(self):
67
+ """Test creating and populating a tag with multiple points"""
68
+ points_data = [
69
+ {"value": 123.45, "timestamp": datetime.now(), "status": "OK"},
70
+ {"value": 124.56, "timestamp": datetime.now(), "status": "OK"}
71
+ ]
72
+
73
+ try:
74
+ result = self.historian_multi.createAndPopulateTag(
75
+ self.test_tag,
76
+ points_data,
77
+ description="Test tag created and populated with list",
78
+ units="test_unit",
79
+ stepped=False,
80
+ update_existing=True
81
+ )
82
+ self.assertIsInstance(result, (bool, dict, list))
83
+ except Exception as e:
84
+ self.skipTest(f"Create and populate tag operation not permitted: {e}")
85
+
86
+
87
+ if __name__ == '__main__':
88
+ unittest.main()