예제 #1
0
파일: tests.py 프로젝트: Lgmrszd/LynxLMS
 def test_case_1(self):
     #db init values
     db_config.init_db('test1.db')
     db_config.drop_tables()
     db_config.create_tables()
     patron = group_manager.Group.create(name = 'patrons', book_ct = 3, book_bestseller_ct = 2, journal_ct = 2, av_ct = 2)
     user = user_manager.User.add(name = 'user_name', surname = 'user_surname', address = 'user_address', phone = 11111111111, group = patron)
     book = doc_manager.Book.create(title = 'Wonderful book', author = 'Nice Author', cost = 500, keywords = 'key', edition = 1, publisher = 'Good publisher', year = 2018)
     copy2 = doc_manager.Copy.add(book)
     copy1 = doc_manager.Copy.add(book)
     #test operations
     bs = booking_system.Booking_system()
     bs.check_out(user, copy1, 'mr. Librarian')
     #check values
     checked_out_copies = 0
     not_checked_out_copies = 0
     for entry in bs.get_document_copies(book):
         if (entry.checked_out):
             checked_out_copies += 1
         else:
             not_checked_out_copies += 1
     self.assertEqual(checked_out_copies, 1)
     self.assertEqual(not_checked_out_copies, 1)
예제 #2
0
    def prepare_database(self):
        db_fname = "test_database.db"
        db_config.init_db(db_fname)
        db_config.drop_tables()
        db_config.create_tables()

        self.g_f = group_manager.Group.add(
            {
                "name": "Faculty",
                "book_ct": 4,
                "book_bestseller_ct": 4,
                "journal_ct": 2,
                "av_ct": 2
            }
        )
        self.g_s = group_manager.Group.add(
            {
                "name": "Students",
                "book_ct": 3,
                "book_bestseller_ct": 2,
                "journal_ct": 2,
                "av_ct": 2
            }
        )
예제 #3
0
def setup_db(db_fname="tests/test_database.db"):
    db_config.init_db(db_fname)
    db_config.drop_tables()
    db_config.create_tables()
예제 #4
0
def prepare_database():
    db_fname = "test_database.db"
    db_config.init_db(db_fname)
    db_config.drop_tables()
    db_config.create_tables()
예제 #5
0
    def prepare_database(self):
        db_fname = "tests/test_database.db"
        db_config.init_db(db_fname)
        db_config.drop_tables()
        db_config.create_tables()
        self.g_f = group_manager.Group.get(
            group_manager.Group.name == 'Faculty')
        self.g_s = group_manager.Group.get(
            group_manager.Group.name == 'Students')
        self.g_v = group_manager.Group.get(
            group_manager.Group.name == 'Visiting professors')

        self.d1 = doc_manager.Book.add({
            "title": "Introduction to Algorithms",
            "author":
            "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein",
            "cost": 5000,
            "keywords": "",
            "edition": "Third edition",
            "publisher": "MIT Press",
            "year": 2009
        })
        self.d2 = doc_manager.Book.add({
            "title":
            "Design Patterns: Elements of Reusable Object-Oriented Software",
            "author":
            "Erich Gamma, Ralph Johnson, John Vlissides, Richard Helm",
            "cost": 1700,
            "keywords": "best seller",
            "edition": "First edition",
            "publisher": "Addison-Wesley Professional",
            "year": 2003
        })
        self.d3 = doc_manager.AVMaterial.add({
            "title": "Null References: The Billion Dollar Mistake",
            "author": "Tony Hoare",
            "cost": 700,
            "keywords": "",
        })
        self.p1 = user_manager.User.add({
            "name": "Sergey",
            "surname": "Afonso",
            "address": "Via Margutta, 3",
            "phone": 30001,
            "group": self.g_f,
            "email": "*****@*****.**"
        })
        self.p2 = user_manager.User.add({
            "name": "Nadia",
            "surname": "Teixeira",
            "address": "Via Sacra, 13",
            "phone": 30002,
            "group": self.g_f,
            "email": "*****@*****.**"
        })
        self.p3 = user_manager.User.add({
            "name": "Elvira",
            "surname": "Espindola",
            "address": "Via del Corso, 22",
            "phone": 30003,
            "group": self.g_f,
            "email": "*****@*****.**"
        })
        self.s = user_manager.User.add({
            "name": "Andrey",
            "surname": "Velo",
            "address": "Avenida Mazatlan 250",
            "phone": 30004,
            "group": self.g_s,
            "email": "*****@*****.**"
        })
        self.v = user_manager.User.add({
            "name": "Veronika",
            "surname": "Rama",
            "address": "Stret Atocha, 27",
            "phone": 30005,
            "group": self.g_v,
            "email": "*****@*****.**"
        })
        self.d1c1 = doc_manager.Copy.add(self.d1)
        self.d1c2 = doc_manager.Copy.add(self.d1)
        self.d1c3 = doc_manager.Copy.add(self.d1)
        self.d2c1 = doc_manager.Copy.add(self.d2)
        self.d2c2 = doc_manager.Copy.add(self.d2)
        self.d2c3 = doc_manager.Copy.add(self.d2)
        self.d3c1 = doc_manager.Copy.add(self.d3)
        self.d3c2 = doc_manager.Copy.add(self.d3)
        self.bsystem = booking_system.Booking_system()