Exemplo n.º 1
0
def InsertFinishedSongStructure(structure):

    #encode
    encoded = EncodeDecode.encodeMessage(structure)
    if encoded is None:
        pass

    cursor, conn = _createcursorandconnection()

    cursor.callproc("InsertSongStructureHash", (encoded, ))
    data = cursor.fetchall()

    if len(data) is 0:
        conn.commit()
        print("successful insertion ")

    else:
        print("something went wrong")
        print(data[0])
Exemplo n.º 2
0
def GetFinishedSongStructure(index):
    if index == None or index < 0:
        ErrorPrinter.invalidDBCallInput("Finished song structure")
        return None

    cursor = _createcursor()

    cursor.callproc("GetSongStructureHash", (index, ))
    data = cursor.fetchall()

    if data == ():
        ErrorPrinter.databaseReturnedNothing("Finished song structure")
        return ""

    cleanData, _ = Util.CleanReturnedList(data)

    #decode
    decoded = EncodeDecode.decodeMessage(cleanData)
    if decoded == None:
        print("unable to decode")
        return ""

    return decoded
Exemplo n.º 3
0
 def testEncodeTrue(self):
     message = "hello world"
     encoded = EncodeDecode.encodeMessage(message)
     encodedTrue = b'aGVsbG8gd29ybGQ='
     self.assertEqual(encoded, encodedTrue)
Exemplo n.º 4
0
    def testDecodeWrongInput(self):
        message = 1
        decode = EncodeDecode.decodeMessage(message)

        self.assertEqual(decode, None)
Exemplo n.º 5
0
 def testDecodeFalse(self):
     message = b'bGVsbG8gd29ybGQ=='
     decode = EncodeDecode.decodeMessage(message)
     decodedTrue = "hello world"
     self.assertNotEqual(decode, decodedTrue)
Exemplo n.º 6
0
 def testEncodeWrongInput(self):
     message = 1
     encode = EncodeDecode.encodeMessage(message)
     self.assertEqual(encode, None)
Exemplo n.º 7
0
 def testEncodeFalse(self):
     message = "hello world"
     encoded = EncodeDecode.encodeMessage(message)
     encodedFalse = b'hello world'
     self.assertNotEqual(encoded, encodedFalse)