[UPD] Delete Library
This commit is contained in:
@@ -80,6 +80,6 @@ class LibraryController:
|
|||||||
self.session.commit()
|
self.session.commit()
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
delete(self.session, self)
|
delete(self.session, self.data)
|
||||||
del(self)
|
del(self)
|
||||||
|
|
||||||
|
|||||||
2
main.py
2
main.py
@@ -1,4 +1,4 @@
|
|||||||
__version__ = "0.2.0.dev"
|
|
||||||
|
|
||||||
from app import app
|
from app import app
|
||||||
from app.config import config
|
from app.config import config
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.exc import NoResultFound
|
||||||
|
|
||||||
from app.api.actions import install
|
from app.api.actions import install
|
||||||
from app.schema.library import Library, Tag, Book, BookTag, Path, Env
|
from app.schema.library import Library, Tag, Book, BookTag, Path, Env
|
||||||
@@ -137,6 +137,11 @@ class TestDB(unittest.TestCase):
|
|||||||
self.assertNotEqual(book.name, "Test book")
|
self.assertNotEqual(book.name, "Test book")
|
||||||
self.assertEqual(book.name, "Another Book on the shelf")
|
self.assertEqual(book.name, "Another Book on the shelf")
|
||||||
|
|
||||||
|
def test_delete_library(self):
|
||||||
|
library = LibraryController(1, engine=self.engine)
|
||||||
|
library.delete()
|
||||||
|
|
||||||
|
self.assertRaises(NoResultFound, LibraryController, 1, engine=self.engine)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
@@ -2,11 +2,13 @@ import os
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
from sqlalchemy.exc import NoResultFound
|
||||||
|
|
||||||
from app.api.actions import install
|
from app.api.actions import install
|
||||||
from app.api.cruds.base import create, read, update
|
from app.api.cruds.base import create, read, update, delete
|
||||||
from app.schema.library import Library, Path, Env, Book, Tag, BookTag
|
from app.schema.library import Library, Path, Env, Book, Tag, BookTag
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -137,6 +139,12 @@ class TestDB(unittest.TestCase):
|
|||||||
self.assertNotEqual(book.name, "Test book")
|
self.assertNotEqual(book.name, "Test book")
|
||||||
self.assertEqual(book.name, "Another Book on the shelf")
|
self.assertEqual(book.name, "Another Book on the shelf")
|
||||||
|
|
||||||
|
def test_delete_library(self):
|
||||||
|
library = read(self.session, 1, Library)
|
||||||
|
delete(self.session, library)
|
||||||
|
|
||||||
|
self.assertRaises(NoResultFound, read, self.session, 1, Library)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
Reference in New Issue
Block a user