python/tests/test_notes.py: add basic tests
authorPaul Brossier <piem@piem.org>
Sun, 18 Dec 2016 10:27:45 +0000 (11:27 +0100)
committerPaul Brossier <piem@piem.org>
Sun, 18 Dec 2016 10:27:45 +0000 (11:27 +0100)
python/tests/test_notes.py [new file with mode: 0644]

diff --git a/python/tests/test_notes.py b/python/tests/test_notes.py
new file mode 100644 (file)
index 0000000..e774907
--- /dev/null
@@ -0,0 +1,42 @@
+#! /usr/bin/env python
+
+from unittest import main
+from numpy.testing import TestCase, assert_equal, assert_almost_equal
+from aubio import notes
+
+AUBIO_DEFAULT_NOTES_SILENCE = -70.
+AUBIO_DEFAULT_NOTES_MINIOI_MS = 30.
+
+class aubio_notes_default(TestCase):
+
+    def test_members(self):
+        o = notes()
+        assert_equal ([o.buf_size, o.hop_size, o.method, o.samplerate],
+            [1024,512,'default',44100])
+
+
+class aubio_notes_params(TestCase):
+
+    samplerate = 44100
+
+    def setUp(self):
+        self.o = notes(samplerate = self.samplerate)
+
+    def test_get_minioi_ms(self):
+        assert_equal (self.o.get_minioi_ms(), AUBIO_DEFAULT_NOTES_MINIOI_MS)
+
+    def test_set_minioi_ms(self):
+        val = 40.
+        self.o.set_minioi_ms(val)
+        assert_almost_equal (self.o.get_minioi_ms(), val)
+
+    def test_get_silence(self):
+        assert_equal (self.o.get_silence(), AUBIO_DEFAULT_NOTES_SILENCE)
+
+    def test_set_silence(self):
+        val = -50
+        self.o.set_silence(val)
+        assert_equal (self.o.get_silence(), val)
+
+if __name__ == '__main__':
+    main()