def test_too_many_entries(self): test_products = list() for i in range(0, 17): test_products.append(Product('ccc33', i)) test_list_server = ListServer(test_products) with self.assertRaises(TooManyProductFoundError): test_list_server.get_entries(3)
def test_get_entries(self): test_list_server = ListServer() p1 = Product('abc44', 222.3) p2 = Product('ab33', 17.23) test_list_server.catalog.append(p1) test_list_server.catalog.append(p2) entries = test_list_server.get_entries(3) self.assertEqual(Counter([p1]), Counter(entries))
def test_add_list(self): test_list_server = ListServer() p1 = Product('abc44', 222.3) p2 = Product('ab33', 17.23) test_list_server.catalog.append(p1) test_list_server.catalog.append(p2) self.assertEqual(test_list_server.catalog[0], p1) self.assertEqual(test_list_server.catalog[1], p2)
def test_client_list_server(self): list_server = ListServer() p1 = Product('abc44', 222.3) p2 = Product('ab33', 17.23) p3 = Product('abc33', 444.4) list_server.add(p1) list_server.add(p2) list_server.add(p3) test_client = Client(list_server) self.assertEqual(17.23, test_client.get_total_price(2))
def test_client_empty_server(self): list_server = ListServer() test_client = Client(list_server) self.assertEqual(None, test_client.get_total_price(2))
def test_remove_list(self): test_list_server1 = ListServer() p1 = Product('abc33', 444.4) test_list_server1.catalog.append(p1) self.assertTrue(True, test_list_server1.remove_product('abc33')) self.assertEqual([], test_list_server1.catalog)
def test_init_list_server_with_param(self): products = [Product('cc444', 4), Product('cds43', 5)] test_list_server = ListServer(products) self.assertTrue(isinstance(test_list_server, ListServer)) self.assertEqual(Counter(products), Counter(test_list_server.catalog))
def test_create_list_server(self): self.assertTrue(isinstance(ListServer(), ListServer))
from product import Product from server import ListServer new_prod = Product('3adf', 333.3) new_prod.name = '33rt' test_list_server = ListServer() p1 = Product('abc33', 444.4) test_list_server.catalog.append(p1) test_list_server.remove_product('abc33') test_server_2 = ListServer()