class MySQLTests(unittest.TestCase): def tearDown(self): self.db.close_connection() time.sleep(0.5) def create_database(self, db_name): subprocess.call([mysql_create_script, "-d", mysql_dump_directory, db_name]) self.db = My_SQL() self.db.open_connection(db_name) def test_fetch_with_song_in_queue(self): """should return the song from 'queue' that has lastplayed_timestamp = 0 with smallest 'timestamp'""" # swamp_test_1 self.create_database("swamp_test_1") song = self.db.fetch_next_song() self.assertEquals("test_uri_2", song["uri"]) def test_fetch_without_song_in_queue(self): """should return the song from 'preset' that is not in 'queue' with smallest 'lastplayed_timestamp'""" # swamp_test_2 self.create_database("swamp_test_2") song = self.db.fetch_next_song() self.assertEquals("test_uri_3", song["uri"])