def setUp(self): self.a = Audio(rel('breakfastTest.wav')) self.b = Audio(rel('WheatiesTest.wav'))
class AudioTest(unittest.TestCase): def setUp(self): self.a = Audio(rel('breakfastTest.wav')) self.b = Audio(rel('WheatiesTest.wav')) def test_audio_from_video(self): v = Video(rel('breakfast.mpg')) self.assertTrue(os.path.exists(v.audio.path)) self.assertAlmostEquals(v.audio.duration, v.duration, delta=0.3) def test_volume(self): output = self.a.set_volume(volume=0.5) self.assertTrue(os.path.exists(output.path)) self.assertEquals(output.duration, self.a.duration) def test_cat(self): self.d = Audio(rel("cancion.wav")) output = self.a.cat(self.d) self.assertAlmostEquals(self.a.duration + self.d.duration, output.duration, delta=0.0000000000001) self.assertTrue(os.path.exists(output.path)) def test_trim(self): output = self.b.trim(start=0, duration=2) self.assertTrue(os.path.exists(output.path)) self.assertEquals(output.duration, 2) output2 = self.b.trim(start=0) self.assertTrue(os.path.exists(output2.path)) self.assertEquals(output2.duration, self.b.duration) def test_duration(self): self.assertEquals(self.a.duration, 1.59) def test_mix(self): output = self.a.mix(self.b) self.assertTrue(os.path.exists(output.path)) self.assertTrue(output.duration in [self.a.duration, self.b.duration]) def test_fadein(self): output = self.b.fade_in(1) self.assertTrue(os.path.exists(output.path)) self.assertEquals(output.duration, self.b.duration) def test_fadeout(self): output = self.b.fade_out(1) self.assertTrue(os.path.exists(output.path)) self.assertEquals(output.duration, self.b.duration) def test_fade(self): output = self.b.fade(0.5, 0.5) self.assertTrue(os.path.exists(output.path)) self.assertEquals(output.duration, self.b.duration) def test_fadedown(self): output = self.b.fade_down(volume=0.1, start=1) self.assertTrue(os.path.exists(output.path)) self.assertEquals(output.duration, self.b.duration) def test_fadeup(self): output = self.b.fade_up(volume=2, start=1) self.assertTrue(os.path.exists(output.path)) self.assertEquals(output.duration, self.b.duration) def test_fadedownsection(self): output = self.b.fade_down_section(volume=1, start=1, end=3) self.assertTrue(os.path.exists(output.path)) self.assertEquals(output.duration, self.b.duration) def test_setstart(self): output = self.b.set_start(start=3) self.assertTrue(os.path.exists(output.path)) self.assertEquals(output.duration, self.b.duration+3)