Skip to content
Snippets Groups Projects
Commit 84ff6780 authored by James Kennington's avatar James Kennington
Browse files

add tests for new conditions of validation

parent c84cce9f
No related tags found
1 merge request!86Add more validation for buffers
Pipeline #690417 failed
"""Tests for sgnts.base.buffer module."""
import numpy
import pytest
from sgnts.base import SeriesBuffer, TSFrame
class TestTSFrame:
"""Test group for TSFrame validation"""
def test_init(self):
"""Test TSFrame initialization"""
b1 = SeriesBuffer(
offset=0, sample_rate=2048, data=numpy.random.rand(2048), shape=(2048,)
)
b2 = SeriesBuffer(
offset=b1.end_offset, sample_rate=2048, data=numpy.random.rand(2048)
)
frame = TSFrame(buffers=[b1, b2])
assert isinstance(frame, TSFrame)
def test_init_err_discontinuous(self):
"""Test TSFrame initialization with error"""
b1 = SeriesBuffer(
offset=0, sample_rate=2048, data=numpy.random.rand(2048), shape=(2048,)
)
b2 = SeriesBuffer(
offset=2*b1.end_offset, sample_rate=2048, data=numpy.random.rand(2048)
)
with pytest.raises(ValueError):
TSFrame(buffers=[b1, b2])
def test_init_err_mixed_types(self):
"""Test TSFrame initialization with error"""
b1 = SeriesBuffer(
offset=0, sample_rate=2048, data=None, shape=(2048,)
)
b2 = SeriesBuffer(
offset=2*b1.end_offset, sample_rate=2048, data=numpy.random.rand(2048)
)
with pytest.raises(ValueError):
TSFrame(buffers=[b1, b2])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment