def setUp(self): super().setUp() self.note0 = notes.add("test0", "test", "test", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) self.note1 = notes.add("test1", "test1", "test1", "*****@*****.**", "0600000000", '12/12/2001', '1A', '../tests/resources/coucou.jpg', True, True ) notes.rebuild_cache() self.win = gui.note_categories_management_window.NoteCategoriesManagementWindow()
def setUp(self): notes.api.redis.send_message = lambda x, y: [notes.rebuild_note_cache(note) for note in y] super().setUp() notes.add("test1", "test1", "test1", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) notes.add("test2", "test2", "test2", "*****@*****.**", "0600000002", '12/12/2002', '2A', '', True, True )
def test_export_by_id(self): notes.add("test0", "test", "test", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) notes.add("test1", "test", "test", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) to_export = ["nickname", "firstname", "lastname", "note", "mail", "photo_path"] note = notes.get(lambda x: x['nickname'] == "test0")[0] csv = ", ".join(to_export) csv += "\n" + ",".join(str(note[value]) for value in to_export) self.assertEqual(csv, notes.export_by_nick(list(["test0"])))
def setUp(self): super().setUp() api.redis.send_message = lambda x, y: [ notes.rebuild_note_cache(note) for note in y ] notes.add("test1", "test1", "test1", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True) self.add_transaction([ "test1", ], -7) notes.add("test2", "test2", "test2", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True) self.add_transaction([ "test2", ], 10) notes.add("test3", "test3", "test3", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True) self.add_transaction([ "test3", ], -10) notes.add("test4", "test4", "test4", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True) self.add_transaction([ "test4", ], 8) notes.add("test12", "test12", "test12", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', False, True) # History transactions.log_transactions([{ 'note': "test1", 'category': "a", 'product': "b", 'price_name': "c", 'quantity': 1, 'price': -1, }]) transactions.log_transactions([{ 'note': "test2", 'category': "a", 'product': "b", 'price_name': "c", 'quantity': 1, 'price': -1, }]) transactions.log_transactions([{ 'note': "test1", 'category': "d", 'product': "e", 'price_name': "f", 'quantity': 1, 'price': -2, }])
def setUp(self): super().setUp() self.note0 = notes.add("test0", "test", "test", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True) self.note1 = notes.add("test1", "test1", "test1", "*****@*****.**", "0600000000", '12/12/2001', '1A', '../tests/resources/coucou.jpg', True, True) notes.rebuild_cache() self.win = gui.note_categories_management_window.NoteCategoriesManagementWindow( )
def setUp(self): super().setUp() self.note0 = notes.add("test0", "test", "test", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True) self.note1 = notes.add("test1", "test1", "test1", "*****@*****.**", "0600000000", '12/12/2001', '1A', '../tests/resources/coucou.jpg', True, True) self.note2 = notes.add("test2", "test2", "test2", "*****@*****.**", "0600000000", '12/12/2001', '1A', '../tests/resources/coucou.jpg', True, True) notes.rebuild_cache()
def test_get_by_id(self): """ Testing get_by_id """ id_ = notes.add("test1", "test", "test", "*****@*****.**", "0600000000", '12/12/2001', '1A', '../tests/resources/coucou.jpg', True, False ) getted = notes.get(lambda x: x['id'] == id_)[0] self.assertEqual(getted, {'id': id_, 'nickname': 'test1', 'lastname': 'test', 'firstname': 'test', 'mail': '*****@*****.**', 'tel': '0600000000', 'birthdate': 1008111600, 'promo': '1A', 'note': 0.0, 'overdraft_date': None, 'ecocups': 0, 'photo_path': 'coucou.jpg', 'tot_cons': 0.0, 'tot_refill': 0.0, 'mails_inscription': False, 'stats_inscription': True, 'agios_inscription': True, 'hidden': False, 'categories': []}) self.assertTrue(os.path.isfile("img/coucou.jpg"))
def test_get_by_majors(self): """ Testing get majors """ id0 = notes.add("test0", "test0", "test0", "*****@*****.**", "0600000000", "24/12/1995", '1A', '', True, True ) notes.add("test1", "test1", "test1", "*****@*****.**", "0600000000", "24/12/1997", '1A', '', True, True ) self.assertEqual(notes.get(lambda x: x["birthdate"] < 851403600), [{'id': id0, 'nickname': 'test0', 'lastname': 'test0', 'firstname': 'test0', 'mail': '*****@*****.**', 'tel': '0600000000', 'birthdate': 819759600, 'promo': '1A', 'note': 0.0, 'tot_cons': 0.0, 'tot_refill': 0.0, 'overdraft_date': None, 'ecocups': 0, 'photo_path': '', 'mails_inscription': True, 'stats_inscription': True, 'agios_inscription': True, 'hidden': False, 'categories': []}])
def test_modif_note(self): """ Testing modifying a note. """ notes.add("test0", "test", "test", "*****@*****.**", "0600000000", "01/01/1994", '1A', '', True, True ) notes.add("crash", "crash", "crash", "*****@*****.**", "0600000000", "01/01/1994", '1A', '', True, True ) notes.change_values("test0", tel="0200000000", promo="3A") note = notes.get()[0] self.assertEqual(note["tel"], "0200000000") self.assertEqual(note["promo"], "3A") notes.change_values("test0", nickname="test1") notes.NOTES_FIELDS_CACHE = {} notes.rebuild_cache() note = notes.get(lambda x: x['nickname'] == "test1")[0] self.assertEqual(note["nickname"], "test1") self.assertEqual(note["tel"], "0200000000") self.assertEqual(note["promo"], "3A") self.assertFalse(notes.change_values("test1", nickname="crash")) note = notes.get(lambda x: x['nickname'] == "test1")[0] self.assertIsNotNone(note)
def test_export_csv(self): """ Testing csv export """ notes.add("test1", "test", "test", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) to_export = ["nickname", "firstname", "lastname", "note", "mail", "photo_path"] note = notes.get()[0] csv = ", ".join(to_export) csv += "\n" + ",".join(str(note[value]) for value in to_export) self.assertEqual(csv, notes.export(notes.get()))
def test_add(self): """ Testing adding notes """ self.assertEqual(notes.add("test1", "test1", "test1", "*****@*****.**", "0600000000", '12/12/2001', '1A', '../tests/resources/coucou.jpg', True, True ), 1) self.assertEqual(notes.add("test2", "test2", "test2", "*****@*****.**", "0600000000", '12/12/2001', '1A', '../tests/resources/coucou.jpg', True, True ), 2) self.assertEqual(notes.add("test2", 15, "test2", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True, ), -1) self.assertEqual(self.count_notes(), 2)
def test_get_by_name(self): """ Testing get_by_name """ notes.add("test0", "test0", "test0", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) notes.add("test1", "test1", "test1", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) notes.add("pouette", "test", "test", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) res = notes.get(lambda x: 'test' in x["nickname"]) for i in range(2): self.assertIn({'id': i + 1, 'nickname': 'test' + str(i), 'lastname': 'test' + str(i), 'firstname': 'test' + str(i), 'mail': '*****@*****.**', 'tel': '0600000000', 'birthdate': 1008111600, 'promo': '1A', 'note': 0.0, 'overdraft_date': None, 'ecocups': 0, 'photo_path': '', 'tot_cons': 0.0, 'tot_refill': 0.0, 'mails_inscription': True, 'stats_inscription': True, 'agios_inscription': True, 'hidden': False, 'categories': []}, res)
def setUp(self): super().setUp() self.note0 = notes.add("test0", "test", "test", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) self.note1 = notes.add("test1", "test1", "test1", "*****@*****.**", "0600000000", '12/12/2001', '1A', '../tests/resources/coucou.jpg', True, True ) self.note2 = notes.add("test2", "test2", "test2", "*****@*****.**", "0600000000", '12/12/2001', '1A', '../tests/resources/coucou.jpg', True, True ) notes.rebuild_cache()
def setUp(self): super().setUp() api.redis.send_message = lambda x, y: [notes.rebuild_note_cache(note) for note in y] notes.add("test1", "test1", "test1", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) self.add_transaction(["test1", ], -7) notes.add("test2", "test2", "test2", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) self.add_transaction(["test2", ], 10) notes.add("test3", "test3", "test3", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) self.add_transaction(["test3", ], -10) notes.add("test4", "test4", "test4", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', True, True ) self.add_transaction(["test4", ], 8) notes.add("test12", "test12", "test12", "*****@*****.**", "0600000000", '12/12/2001', '1A', '', False, True ) # History transactions.log_transactions([{ 'note': "test1", 'category': "a", 'product': "b", 'price_name': "c", 'quantity': 1, 'price': -1, }]) transactions.log_transactions([{ 'note': "test2", 'category': "a", 'product': "b", 'price_name': "c", 'quantity': 1, 'price': -1, }]) transactions.log_transactions([{ 'note': "test1", 'category': "d", 'product': "e", 'price_name': "f", 'quantity': 1, 'price': -2, }])