def test_song_edit(self): file1 = models.File(filename ="File1") file2 = models.File(filename = "File2") session.add_all([file1, file2]) session.commit() song1 = models.Song(original_file_id=file1.id) session.add(song1) session.commit() data = { "file": { "id" : file2.id } } response = self.client.put("/api/songs/{}".format(song1.id), data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, "application/json") songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.original_file_id, file2.id)
def test_post_song(self): # test posting song into db file_A = models.File(name='file_A.mp3') session.add(file_A) session.commit() data = {"file": {"id": file_A.id}} response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") data = json.loads(response.data.decode("ascii")) self.assertEqual(data["id"], 1) self.assertEqual(data["file"]["id"], 1) self.assertEqual(data["file"]["name"], "file_A.mp3") songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.id, 1) self.assertEqual(song.file.id, 1) self.assertEqual(song.file.name, "file_A.mp3")
def test_post_file(self): fileA = models.File(filename="testA.wav") session.add(fileA) session.commit() fileA_post = { "file":{ "id": fileA.id } } # data = fileA.as_dictionary() data = fileA_post response = self.client.post("api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual(urlparse(response.headers.get("Location")).path, "/api/songs/1") data = json.loads(response.data.decode("ascii")) self.assertEqual(data["id"], 1) self.assertEqual(data["file"]["filename"], "testA.wav") songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.file.filename, "testA.wav")
def test_post_song(self): """ Test post song """ file1 = models.File(filename="file1Song") session.add(file1) session.commit() data = { "file": { "id": file1.id } } response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual(urlparse(response.headers.get("Location")).path, "/api/songs/1") data = json.loads(response.data.decode("ascii")) self.assertEqual(data["id"], 1) songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.id, 1)
def test_songs_post(self): """ Posting a new song """ data = { "file": { "id" : 1 } } file = models.File(name="Test File") session.add(file) session.commit() response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") # self.assertEqual(urlparse(response.headers.get("Location")).path, # "/api/songs/1") data = json.loads(response.data.decode("ascii")) self.assertEqual(data["file"]["id"], 1) self.assertEqual(data["file"]["name"], "Test File") songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.file.name, "Test File")
def test_post_song(self): "post a song for file in DB - success" #add a song file to the DB for the test file = models.File(filename="Plains.mp3") session.add(file) session.commit() print(file.id) print(file.filename) data = { "songname": "Plains", "file": { "file": file.id } } #query api response = self.client.get("/api/songs") print(response) #assert api response contains expected response self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, "application/json") data = json.loads(response.data.decode("ascii")) self.assertEqual(len(data), 1) #assert response contains expected songs/file song1 = data[0] print(song1) self.assertEqual(song1["songname"], "Plains") self.assertEqual(song1["file"]["filename"], "Plains.mp3") self.assertEqual(song1["file"]["id"], song1["id"])
def test_post_song(self): """ Posting a new song """ fileA = models.File(filename='FileA') session.add(fileA) session.commit() song_payload = { "file": { "id": fileA.id } } response = self.client.post("/api/songs", data=json.dumps(song_payload), content_type="application/json", headers=[("Accept", "application/json")]) print response.data print fileA.id self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual(urlparse(response.headers.get( "Location")).path, "/api/songs") data = json.loads(response.data) self.assertEqual(data["id"], fileA.id) # self.assertEqual(data["song_file"], "techno") songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.id, fileA.id)
def testPostSong(self): """ Add a new song """ # Add a file to the database to test against fileA = models.File(filename="FileA.mp3") session.add(fileA) session.commit() data = json.dumps({"file": {"id": 1}}) response = self.client.post("/api/songs", data=data, content_type="application/json", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual(urlparse(response.headers.get("Location")).path, "/api/songs/1") data = json.loads(response.data) self.assertEqual(data["id"], 1) self.assertEqual(data["file"]["id"], 1) self.assertEqual(data["file"]["name"], "FileA.mp3") songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.id, 1) self.assertEqual(song.file.id, 1) self.assertEqual(song.file.filename, "FileA.mp3")
def test_post_file(self): fileA = models.File(filename="testA.wav") session.add(fileA) session.commit() fileA_post = {"file": {"id": fileA.id}} # data = fileA.as_dictionary() data = fileA_post response = self.client.post("api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual( urlparse(response.headers.get("Location")).path, "/api/songs/1") data = json.loads(response.data.decode("ascii")) self.assertEqual(data["id"], 1) self.assertEqual(data["file"]["filename"], "testA.wav") songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.file.filename, "testA.wav")
def test_add_song(self): """Getting posts from a populated database""" fileA = models.File(name='fileA.mp3') session.add(fileA) session.commit() response = self.client.post('/api/songs', headers=[('Accept', 'application/json')], content_type='application/json', data=json.dumps({'file': {'id': 1}}) ) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, 'application/json') #self.assertEqual(urlparse(response.headers.get("Location")).path, '/') songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.id, 1) self.assertEqual(song.file.id, 1) self.assertEqual(song.file.name, 'fileA.mp3') data = json.loads(response.data.decode('ascii')) self.assertEqual(len(data), 1) songA = data[0] self.assertEqual(songA['id'], 1) self.assertEqual(songA['file'], {'id': 1, 'name': 'fileA.mp3'})
def test_edit_song(self): #Editing an existing song file = models.File(name="Example.mp3") song = models.Song(file=file) session.add(song) session.commit() data = { "name": "Edited.mp3", } response = self.client.put("/api/songs/{}".format(song.id), data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, "application/json") self.assertEqual( urlparse(response.headers.get("Location")).path, "/api/songs/{}".format(song.id)) data = json.loads(response.data.decode("ascii")) self.assertEqual(data["id"], 1) self.assertEqual(data["file"]["name"], "Edited.mp3") # Assert that there is only one song in the database songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) # Assert that the name was changed song = songs[0] self.assertEqual(file.name, "Edited.mp3")
def test_add_song(self): """testing adding a song to the database""" fileA = models.File(name="moonlight.mp3") session.add(fileA) session.commit() data = { "file": { "id": fileA.id } } #print(data) response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual(urlparse(response.headers.get("Location")).path,"/api/songs") data = json.loads(response.data.decode("ascii")) #print(data) self.assertEqual(data["id"], fileA.id) songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.id, fileA.id)
def test_post_song(self): """ Adding a new song """ fileA = models.File(name="test-feb14.mp3") session.add(fileA) session.commit() data = {"file": {"id": 1}} response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual( urlparse(response.headers.get("Location")).path, "/api/songs/1") data = json.loads(response.data.decode("ascii")) self.assertEqual(data['id'], 1) self.assertEqual(data['file']['name'], 'test-feb14.mp3') file = session.query(models.File).all() song = session.query(models.Song).all() self.assertEqual(len(file), 1) self.assertEqual(len(song), 1) file = file[0] song = song[0] print(file) self.assertEqual(file.id, 1) self.assertEqual(file.name, 'test-feb14.mp3') self.assertEqual(song.id, 1) self.assertEqual(song.file, file)
def test_song_post(self): """ Add a new song """ file = models.File(name="green_song.mp3") session.add(file) session.commit() data = { "file": { "id": file.id } } response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.file.id, file.id) data = json.loads(response.data) self.assertEqual(data["file"]["id"], file.id) self.assertEqual(urlparse(data["file"]["path"]).path, "/uploads/green_song.mp3")
def seed(): for i in range(25): file = File(name="TestFile{}.mp3".format(i)) session.add(file) session.commit() song = Song(file_id=file.id) session.add(song) session.commit()
def seed(): for i in range(25): song = Song() file = File(filename='test song {}'.format(i) ) song.file = file session.add(song) session.commit()
def test_delete_song(self): """ delete songs from database """ fileA = models.File(name="Shady_Grove.mp3") session.add(fileA) session.commit() response = self.client.delete("/api/songs/{}".format(fileA.id), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 204)
def test_get_songs(self): fileA = models.File(name='fileA.mp3') session.add(fileA) session.commit() songA = models.Song(file_id=fileA.id) session.add(songA) session.commit() fileB = models.File(name='fileB.mp3') session.add(fileB) session.commit() songB = models.Song(file_id=fileB.id) session.add(songB) session.commit() response = self.client.get('/api/songs', headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, 'application/json') data = json.loads(response.data.decode('ascii')) SongA, SongB = data self.assertEqual(SongA['id'], songA.id) self.assertEqual(SongA['file']['id'], songA.file_id) self.assertEqual(SongB['id'], songB.id) self.assertEqual(SongB['file']['id'], songB.file_id)
def testPostNewSong(self): """Post a new song to the DB""" # Create a file in the DB for the app to find file = models.File(name="BornThisWay.mp3") session.add(file) session.commit() # Compile posted data into a dictionary for easy conversion to JSON data = { "file": { "id": 1 } } # Collect the response from the endpoint # use json.dumps to convert dict > JSON # use content_type to indicate the type of content in data response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")], ) # Verify request to endpoint was successful using 201 created self.assertEqual(response.status_code, 201) # Verify that the response is JSON type self.assertEqual(response.mimetype, "application/json") # Verify the endpoint is setting the correct Location header # This should be the link to the new post self.assertEqual(urlparse(response.headers.get("Location")).path, "/api/songs") # Decode the response with json.loads song = json.loads(response.data) # Extrapolate the file info file = song["file"] # Validate the response self.assertEqual(song["id"], 1) self.assertEqual(file["id"], 1) self.assertEqual(file["name"], "BornThisWay.mp3") # Query DB to validate status song = session.query(models.Song).all() # Verify only one item in DB self.assertEqual(len(song), 1) # Isolate the one item in the list song = song[0] # Validate the content of the item retrieved from the DB self.assertEqual(song.id, 1) self.assertEqual(song.file_id, 1) self.assertEqual(song.file.name, "BornThisWay.mp3")
def post_songs(self): """ Post songs Test """ test_song = {"file": {"id": 9}} new_song = models.Song(test_song) session.add(test_song) session.commit() response = self.client.post("/api/songs") self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, "application/json") data = json.loads(response.data.decode("ascii")) self.assertEqual(len(data), 2)
def test_delete_success(self): """ Test successful song deletion """ song = models.Song() session.add(song) session.commit() data = { "id": song.id } response = self.client.delete("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 302)
def test_post_song_successful(self): file = models.File(filename="Soulful Strut.mp3") session.add(file) session.commit() data = { "file": { "id": file.id } } response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 302) self.assertEqual(response.mimetype, "text/html")
def testPostNewSong(self): """Post a new song to the DB""" # Create a file in the DB for the app to find file = models.File(name="BornThisWay.mp3") session.add(file) session.commit() # Compile posted data into a dictionary for easy conversion to JSON data = {"file": {"id": 1}} # Collect the response from the endpoint # use json.dumps to convert dict > JSON # use content_type to indicate the type of content in data response = self.client.post( "/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")], ) # Verify request to endpoint was successful using 201 created self.assertEqual(response.status_code, 201) # Verify that the response is JSON type self.assertEqual(response.mimetype, "application/json") # Verify the endpoint is setting the correct Location header # This should be the link to the new post self.assertEqual( urlparse(response.headers.get("Location")).path, "/api/songs") # Decode the response with json.loads song = json.loads(response.data) # Extrapolate the file info file = song["file"] # Validate the response self.assertEqual(song["id"], 1) self.assertEqual(file["id"], 1) self.assertEqual(file["name"], "BornThisWay.mp3") # Query DB to validate status song = session.query(models.Song).all() # Verify only one item in DB self.assertEqual(len(song), 1) # Isolate the one item in the list song = song[0] # Validate the content of the item retrieved from the DB self.assertEqual(song.id, 1) self.assertEqual(song.file_id, 1) self.assertEqual(song.file.name, "BornThisWay.mp3")
def testPostSongInvalidData(self): """ Trying to add a new song but passing invalid data """ fileA = models.File(filename = "FileA.mp3") session.add(fileA) session.commit() data = json.dumps({"file": {"id": "invaliddata"}}) response = self.client.post("/api/songs", data=data, content_type="application/json", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 422) data = json.loads(response.data) self.assertEqual(data["message"], "u'invaliddata' is not of type 'integer'")
def test_delete_single_song(self): """ Deleting a single song from the database """ fileA = models.File(filename="FileA.mp3") session.add(fileA) session.commit() songA = models.Song(song_file_id=fileA.id) session.add(songA) session.commit() response = self.client.delete("/api/songs/{}".format(songA.id), headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, "application/json") songs = session.query(models.Song).all() self.assertEqual(len(songs), 0)
def test_put_song(self): file = models.File(name="Shady_Grove.mp3") session.add(file) session.commit() data = {"file": {"name": "gees.mp3"}} #Check request to endpoint is succesful response = self.client.put("/api/songs/{}".format(file.id), data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual( urlparse(response.headers.get("Location")).path, "/api/songs/{}".format(file.id))
def test_get_single_song(self): """ Getting a single song from the database """ fileA = models.File(filename="FileA.mp3") session.add(fileA) session.commit() songA = models.Song(song_file_id=fileA.id) session.add(songA) session.commit() response = self.client.get("/api/songs/{}".format(songA.id), headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, "application/json") song = json.loads(response.data) self.assertEqual(song["id"], song["file"]["id"]) self.assertEqual(song["file"]["name"], "FileA.mp3")
def test_get_songs(self): """ Test get songs """ file1 = models.File(filename="file1Song") session.add(file1) session.commit() song1 = models.Song(file_id=file1.id) session.add(song1) session.commit() response = self.client.get("/api/songs", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, "application/json") data = json.loads(response.data.decode("ascii")) self.assertEqual(len(data), 1)
def testPostSongMissingData(self): """ Trying to add a new song but missing the file id """ fileA = models.File(filename = "FileA.mp3") session.add(fileA) session.commit() data = json.dumps({"file": {}}) response = self.client.post("/api/songs", data=data, content_type="application/json", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 422) self.assertEqual(response.mimetype, "application/json") data = json.loads(response.data) self.assertEqual(data["message"], "'id' is a required property")
def test_post_songs(self): """ Post songs Test """ test_file = models.File(name="test_file") session.add(test_file) session.commit() file_test = session.query(models.File).order_by( models.File.name).first() new_song = models.Song(file=file_test) session.add(new_song) session.commit() response = self.client.post("/api/songs") self.assertEqual(response.status_code, 415) self.assertEqual(response.mimetype, "application/json")
def test_new_song(self): """ Add a song to the database """ testfile = File(name="chords.wav") session.add(testfile) session.commit() data = {"file": {"id": 1}} response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") data = json.loads(response.data.decode("ascii")) self.assertEqual(data[0]["id"], 1) self.assertEqual(data[0]["file"]["id"], 1) self.assertEqual(data[0]["file"]["name"], "chords.wav")
def test_delete_song(self): new_file = models.File(name='New_File') session.add(new_file) session.commit() new_song = models.Song(file_id=new_file.id) session.add(new_song) session.commit() response = self.client.delete("/api/songs/{}".format(new_song.id), headers=[("Accept", "application/json")]) session.delete(new_file) session.commit() self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, "application/json") songs = session.query(models.Song).all() self.assertEqual(len(songs), 0)
def test_add_song(self): """ Adding a song to the databse """ #create songs fileA = models.File(filename='test_file') session.add(fileA) session.commit() data = { "file": { "id": 1 } } response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers = [("Accept", "application/json")] ) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json")
def test_delete_song(self): """ Deleting a song from the app """ new_file = models.File(filename='New_File') session.add(new_file) session.commit() new_song = models.Song(song_file_id=new_file.id) session.add(new_song) session.commit() response = self.client.delete( "/api/songs/{}".format(new_song.id), headers=[("Accept", "application/json")]) session.delete(new_file) session.commit() self.assertEqual(response.status_code, 200) self.assertEqual(response.mimetype, "application/json") songs = session.query(models.Song).all() self.assertEqual(len(songs), 0)
def test_post_song(self): """ Posting a new song """ fileA = models.File(name="A test") session.add(fileA) session.commit() data = { "id": fileA.id } response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual(urlparse(response.headers.get("Location")).path, "/api/songs/1")
def test_post_song(self): """ Posting a song """ file = models.File(name="fileA") session.add(file) session.commit() data = {"file": {"id": file.id}} response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual( urlparse(response.headers.get("Location")).path, "/api/songs") data = json.loads(response.data.decode("ascii")) self.assertEqual(data["id"], 1) songs = session.query(models.Song).all() self.assertEqual(len(songs), 1)
def test_post_song(self): """Testing post songs endpoint""" file = models.File(name="Shady_Grove.mp3") session.add(file) session.commit() data = {"file": {"id": 1}} #Check request to endpoint is succesful response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") self.assertEqual( urlparse(response.headers.get("Location")).path, "/api/songs") data = json.loads(response.data.decode("ascii")) self.assertEqual(data["id"], 1) self.assertEqual(file.name, "Shady_Grove.mp3")
def test_post_song(self): ''' posting a new song ''' file = models.File(filename = 'Test Song.mp3') session.add(file) session.commit() data = { "file": { "id": 1 } } response = self.client.post('/api/songs', data = json.dumps(data), content_type = 'application/json', headers = [('Accept', 'application/json')] ) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, 'application/json') self.assertEqual(urlparse(response.headers.get('Location')).path, '/api/songs/1') data = json.loads(response.data.decode('ascii')) self.assertEqual(data['id'], 1) self.assertEqual(data['file']['id'], file.id) self.assertEqual(data['file']['name'], 'Test Song.mp3') songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.id, 1) self.assertEqual(song.file.id, 1) self.assertEqual(song.file.filename, 'Test Song.mp3')
def test_song_post(self): file = models.File(filename="example.mp3") session.add(file) session.commit() data = { "file": { "id": file.id } } response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")] ) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") data = json.loads(response.data) self.assertEqual(data["file"]["id"], file.id) self.assertEqual(urlparse(data["file"]["path"]).path, "/uploads/example.mp3")
def test_post_song(self): """ Posting a new song """ songA = models.File(filename="Drones.mp3") session.add(songA) session.commit() data = {"file": {"id": 1}} response = self.client.post("/api/songs", data=json.dumps(data), content_type="application/json", headers=[("Accept", "application/json")]) self.assertEqual(response.status_code, 201) self.assertEqual(response.mimetype, "application/json") data = json.loads(response.data.decode("ascii")) self.assertEqual(data["file"]["id"], 1) self.assertEqual(data["file"]["filename"], "Drones.mp3") songs = session.query(models.Song).all() self.assertEqual(len(songs), 1) song = songs[0] self.assertEqual(song.file_id, 1)
def seed(): FileA = models.File(name="beyonce.mp3") songA = models.Song(file=FileA) session.add(songA) session.commit()