def test_compare_without_results(self): books = ['Some book', 'Another Book', 'The Book'] authors = ['Some Author', 'Another Author', 'The Author'] my_list = ['Some book', 'Another Author', 'Author', 'The Book'] input_list = ['Another Book', 'The Book', 'Some Book'] for book, author in zip(books, authors): response, err = inventory.insert(book=book, authors=[author]) assert response result = inventory.compare(my_list=my_list, input_list=input_list) assert len(result) == 0
def test_compare_without_results(self): books = ["Some book", "Another Book", "The Book"] authors = ["Some Author", "Another Author", "The Author"] my_list = ["Some book", "Another Author", "Author", "The Book"] input_list = ["Another Book", "The Book", "Some Book"] for book, author in zip(books, authors): response, err = inventory.insert(book=book, authors=[author]) assert response result = inventory.compare(my_list=my_list, input_list=input_list) assert len(result) == 0
elif cmd[0] == "su-fi": fish.edit() elif cmd[0] == "su-mi": misc.edit() elif cmd[0] == "ai": inv.add(cmd[1], ins.search(cmd[1])) elif cmd[0] == "af": inv.add(cmd[1], fish.search(cmd[1])) elif cmd[0] == "am": inv.add(cmd[1], misc.search(cmd[1])) elif cmd[0] == "si": print(ins.search(cmd[1])) elif cmd[0] == "sf": print(fish.search(cmd[1])) elif cmd[0] == "sm": print(misc.search(cmd[1])) elif cmd[0] == "ci": print(inv.compare(ins.search(cmd[1]))) elif cmd[0] == "cf": print(inv.compare(fish.search(cmd[1]))) elif cmd[0] == "cm": print(inv.compare(misc.search(cmd[1]))) elif cmd[0] == "r": inv.remove(cmd[1]) elif cmd[0] == "w": inv.clear() cmd = input(":").split(" ", 1) if (cmd[0] == "q"): inv.write()
import sys import json import inventory if __name__ == '__main__': try: with open('data.json', 'r') as f: input_data = json.loads(f.read()) except IOError as e: sys.stdout.write('[error] data.json file is missing,' ' rename the data.json.example to data.json\n') sys.exit(1) for book, authors in input_data['inventory'].items(): inventory.insert(book=book, authors=authors) sys.stdout.write('Missing books:\n') for i, b in enumerate( inventory.compare(my_list=input_data['my_list'], input_list=input_data['input_list'])): sys.stdout.write('{}. {}\n'.format(i + 1, b))
import sys import json import inventory if __name__ == '__main__': try: with open('data.json', 'r') as f: input_data = json.loads(f.read()) except IOError as e: sys.stdout.write('[error] data.json file is missing,' ' rename the data.json.example to data.json\n') sys.exit(1) for book, authors in input_data['inventory'].items(): inventory.insert(book=book, authors=authors) sys.stdout.write('Missing books:\n') for i, b in enumerate(inventory.compare( my_list=input_data['my_list'], input_list=input_data['input_list'])): sys.stdout.write('{}. {}\n'.format(i + 1, b))