def __init__(self): print '''Would you like to: 1. Go somewhere 2. Call someone 3. Read a book 4. Play video games ''' choice = raw_input(">: ") if choice == "1": print '''Where would you like to go? 1. Library 2. Gym 3. Supermarket ''' choice = raw_input(">: ") if choice == "1": Library() elif choice == "2": Gym() else: Groceries() elif choice == "2": Call() elif choice == "3": Book() else: VideoGames()
def setUp(self, mockBooks_API, mockLibrary_DB): self.library = Library() self.patron = Patron("bob", "bobson", 41, 1) self.library.api = mockBooks_API self.library.db = mockLibrary_DB mockBooks_API.get_ebooks.return_value = [{ 'title': 'The Count of Monte Cristo', "ebook_count": 1 }, { 'title': 'A Tale of Two Cities', "ebook_count": 1 }, { 'title': '1984', "ebook_count": 1 }, { 'title': 'Slaughterhouse 5', "ebook_count": 1 }, { 'title': 'Breakfast of Champions', "ebook_count": 1 }] mockBooks_API.books_by_author.return_value = [ 'Slaughterhouse 5', 'Breakfast of Champions' ] mockBooks_API.get_book_info.return_value = [{ 'title': 'The Count of Monte Cristo', "ebook_count": 1, 'publisher': 'Penguin', 'publish_year': '1844', 'language': "french" }] mockLibrary_DB.patrons = [self.patron] mockLibrary_DB.update_patron = self.mock_update_patron mockLibrary_DB.insert_patron.return_value = 1 mockLibrary_DB.retrieve_patron = self.mock_retrieve_patron
def setUp(self) -> None: self.CuT = Library() self.CuT.db.close_db() self.patron = Mock() self.book_title_there = 'Adventures of Elvis' self.book_title_not_there = 'Adventures of Dino' self.book_title_language = 'Harry Potter' self.book_author = 'Dummy Name' self.first_name = 'Sam' self.last_name = 'Wheeler' self.age = 27 self.member_id = 100001
def showAddDialog(self, tab: Type[BackendTab]) -> None: library: Library = Library() dlg: DetailsDialog = DetailsDialog(tab, library, self) success: int = dlg.exec_() if not success: return library.save() self._library_manager.addLibrary(library) self.libraries_model.reloadLibraries()
def OnInit(self): import Inspectors, Layouts, Shapes # pylint: disable=W0612 neuroptikon.library = Library() self._loadDefaultLibraryItems() neuroptikon.config = wx.Config('Neuroptikon') if platform.system() == 'Darwin': wx.MenuBar.MacSetCommonMenuBar(self.menuBar()) neuroptikon.scriptLocals = self.scriptLocals self.preferences = Preferences() self.inspector = InspectorFrame() self.SetExitOnFrameDelete(False) startupScript = neuroptikon.config.Read('Startup Script', '') try: exec startupScript in self.scriptLocals() except: (exceptionType, exceptionValue, exceptionTraceback) = sys.exc_info() frames = traceback.extract_tb(exceptionTraceback)[1:] message = gettext( 'An error occurred while running the startup script:') subMessage = str( exceptionValue ) + ' (' + exceptionType.__name__ + ')' + '\n\nTraceback:\n' + ''.join( traceback.format_list(frames)) if platform.system() == 'Darwin': wx.MessageBox(subMessage, message, style=wx.ICON_ERROR | wx.OK) else: wx.MessageBox(message + '\n\n' + subMessage, 'Neuroptikon', parent=self, style=wx.ICON_ERROR | wx.OK) # open an empty network by default # TODO: pref to re-open last doc? self.onNewNetwork() return True
from library.library import Library from library.user import User user = User(12, 'Peter') library = Library() library.add_user(user) print(library.add_user(user)) library.remove_user(user) print(library.remove_user(user)) library.add_user(user) print(library.change_username(2, 'Igor')) print(library.change_username(12, 'Peter')) print(library.change_username(12, 'George')) [ print( f'{user_record.user_id}, {user_record.username}, {user_record.books}') for user_record in library.user_records ] library.books_available.update({ 'J.K.Rowling': [ 'The Chamber of Secrets', 'The Prisoner of Azkaban', 'The Goblet of Fire', 'The Order of the Phoenix', 'The Half-Blood Prince', 'The Deathly Hallows' ] }) user.get_book('J.K.Rowling', 'The Deathly Hallows', 17, library) print(library.books_available) print(library.rented_books) print(user.books)