diff options
author | Théo de la Hogue | 2022-11-23 10:55:30 +0100 |
---|---|---|
committer | Théo de la Hogue | 2022-11-23 10:55:30 +0100 |
commit | 41fe51942dac48cb23c6c946ee1d53b90562051f (patch) | |
tree | a378c893eab8594470341344c512ff5f73222c3a /src/argaze.test | |
parent | 59ed28117275827303854cabe50339c34499f5aa (diff) | |
download | argaze-41fe51942dac48cb23c6c946ee1d53b90562051f.zip argaze-41fe51942dac48cb23c6c946ee1d53b90562051f.tar.gz argaze-41fe51942dac48cb23c6c946ee1d53b90562051f.tar.bz2 argaze-41fe51942dac48cb23c6c946ee1d53b90562051f.tar.xz |
Allowing to store dict wit hcorrect keys as GazePosition in TimeStampedGazePositions buffer.
Diffstat (limited to 'src/argaze.test')
-rw-r--r-- | src/argaze.test/GazeFeatures.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/argaze.test/GazeFeatures.py b/src/argaze.test/GazeFeatures.py index 5a3c2d9..dd0717c 100644 --- a/src/argaze.test/GazeFeatures.py +++ b/src/argaze.test/GazeFeatures.py @@ -117,6 +117,7 @@ class TestTimeStampedGazePositionsClass(unittest.TestCase): ts_gaze_positions = GazeFeatures.TimeStampedGazePositions() ts_gaze_positions[0] = GazeFeatures.GazePosition() ts_gaze_positions[1] = GazeFeatures.UnvalidGazePosition() + ts_gaze_positions[2] = {"value": (0, 0), "accuracy": 0.} # Check GazePosition is correctly stored and accessible as a GazePosition self.assertIsInstance(ts_gaze_positions[0], GazeFeatures.GazePosition) @@ -126,13 +127,22 @@ class TestTimeStampedGazePositionsClass(unittest.TestCase): self.assertIsInstance(ts_gaze_positions[1], GazeFeatures.UnvalidGazePosition) self.assertEqual(ts_gaze_positions[1].valid, False) + # Check dict with "value" and "accuracy" keys is correctly stored and accessible as a GazePosition + self.assertIsInstance(ts_gaze_positions[2], GazeFeatures.GazePosition) + self.assertEqual(ts_gaze_positions[2].valid, True) + # Check that bad data type insertion fails with self.assertRaises(AssertionError): - ts_gaze_positions[2] = "This string is not a gaze position value." + ts_gaze_positions[3] = "This string is not a gaze position value." + + # Check that dict with bad keys insertion fails + with self.assertRaises(AssertionError): + + ts_gaze_positions[4] = {"bad_key": (0, 0), "accuracy": 0.} # Check final lenght - self.assertEqual(len(ts_gaze_positions), 2) + self.assertEqual(len(ts_gaze_positions), 3) def test___repr__(self): """Test inherited string representation.""" |