Пример #1
0
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"])
Пример #2
0
def main():
    # initialize
    global db
    global state
    global player
    db = My_SQL()
    db.open_connection()
    
    state = {
        "init": False,
        "playing": False,
        "song": {
            "uri": "",
            "title": "",
            "artist": "",
            "album": "",
            "length_sec": 0
        }
    }
    
    player = Spotify()
    
    # Note: for whatever reason, having the debugger on will do some weird stuff
    # with the cleanup function
    app.debug = True # TURN THIS OFF IN PRODUCTION
    app.run(port=8000)
    
    # clean up before exiting
    cleanup()
Пример #3
0
 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)