From 3f70f41991199732a9ad336be713129848329ade Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jose=20Nu=C3=B1ez?= <jnunyez@users.noreply.github.com>
Date: Wed, 25 Oct 2023 19:57:09 +0200
Subject: [PATCH] add failure missing test samples

---
 src/vse_sync_pp/analyzers/analyzer.py      |  2 ++
 tests/vse_sync_pp/analyzers/test_ts2phc.py | 32 ++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/src/vse_sync_pp/analyzers/analyzer.py b/src/vse_sync_pp/analyzers/analyzer.py
index 32886e5..95ae1fc 100644
--- a/src/vse_sync_pp/analyzers/analyzer.py
+++ b/src/vse_sync_pp/analyzers/analyzer.py
@@ -260,6 +260,8 @@ def test(self, data):
             return (False, "short test duration")
         if len(data) - 1 < self._duration_min:
             return (False, "short test samples")
+        if len(data.timestamp.diff().astype(float).round(0).tail(-1).unique()) > 1:
+            return (False, "missing test samples")
         return (True, None)
 
     def explain(self, data):
diff --git a/tests/vse_sync_pp/analyzers/test_ts2phc.py b/tests/vse_sync_pp/analyzers/test_ts2phc.py
index 4e241a8..cc4a8ef 100644
--- a/tests/vse_sync_pp/analyzers/test_ts2phc.py
+++ b/tests/vse_sync_pp/analyzers/test_ts2phc.py
@@ -185,6 +185,38 @@ class TestTimeErrorAnalyzer(TestCase, metaclass=AnalyzerTestBuilder):
                 },
             },
         },
+        {
+            'requirements': 'G.8272/PRTC-A',
+            'parameters': {
+                'time-error-limit/%': 100,
+                'transient-period/s': 1,
+                'min-test-duration/s': 4,
+            },
+            'rows': (
+                TERR(Decimal(0), 0, 's2'),
+                TERR(Decimal(1), 0, 's2'),
+                TERR(Decimal(2), 0, 's2'),
+                TERR(Decimal(3), 0, 's2'),
+                # oops, missing sample
+                TERR(Decimal(5), 0, 's2'),
+                TERR(Decimal(6), 0, 's2'),
+            ),
+            'result': False,
+            'reason': "missing test samples",
+            'timestamp': Decimal(1),
+            'duration': Decimal(5),
+            'analysis': {
+                'terror': {
+                    'units': 'ns',
+                    'min': 0,
+                    'max': 0,
+                    'range': 0,
+                    'mean': 0,
+                    'stddev': 0,
+                    'variance': 0,
+                },
+            },
+        },
         {
             'requirements': 'G.8272/PRTC-A',
             'parameters': {