def test_too_many_products_search_error(self):
     products = [Product(f'PP{x}{x}', 3) for x in range(Server.n_max_returned_entries + 1)]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         entries = client.get_total_price(2)
         self.assertIsNone(entries)
Example #2
0
 def test_get_total_price(self):
     products = [
         Product('PP234', 2),
         Product('PP235', 3),
         Product('PP236', 4),
         Product('PP237', 5)
     ]
     client = Client(ListServer(products))
     self.assertEqual(client.get_total_price(2), None)
     client1 = Client(ListServer(products[:3]))
     self.assertEqual(client1.get_total_price(2), 9)
     client3 = Client(
         ListServer(
             [Product('A12', 2),
              Product('ab1', 3),
              Product('Ab1234', 4)]))
     self.assertEqual(client3.get_total_price(2), None)
 def test_None_for_MAP(self):
     products = [
         Product('PPP234', 2),
         Product('PPP235', 3),
         Product('PPP236', 4)
     ]
     server = MapServer(products)
     client = Client(server)
     prod = client.get_total_price(2)
     self.assertEqual(prod, None)
Example #4
0
 def test_total_price_for_price_list_is_empty(self):
     products = [
         Product('PP246', 4),
         Product('PP235', 2),
         Product('PP543', 6),
         Product('PP278', 4)
     ]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertEqual(None, client.get_total_price(3))
Example #5
0
 def test_total_price_for_exceptions_execution(self):
     products = [
         Product('PP246', 4),
         Product('PP235', 2),
         Product('PP543', 6),
         Product('PP278', 4)
     ]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertEqual(None, client.get_total_price(2))
Example #6
0
 def test_total_price_for_sum_eq_0_execution2(self):
     products = [
         Product('PP234', 0),
         Product('PP235', 0),
         Product('PP236', 0),
         Product('PP237', 0),
         Product('PPP238', 1)
     ]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertEqual(None, client.get_total_price(4))
Example #7
0
 def test_total_price_for_exeptional_execution(self):
     products = [
         Product('PP234', 2),
         Product('PP235', 3),
         Product('PP236', 1),
         Product('PP237', 5),
         Product('PPP238', 1)
     ]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertEqual(None, client.get_total_price(2))
Example #8
0
 def test_total_price_for_None(self):
     products = [
         Product('P12', 1),
         Product('PP234', 2),
         Product('PP235', 1),
         Product('PP24', 2),
         Product('PP34', 2)
     ]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertIsNone(client.get_total_price(2))
Example #9
0
 def test_price_error(self):
     products = [
         Product('aa11', 1),
         Product('aa13', 3),
         Product('aa12', 2),
         Product('aa15', 5),
         Product('aa14', 4)
     ]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertEqual(None, client.get_total_price(2))
Example #10
0
 def test_total_price_for_no_entries_found(self):
     products = [
         Product('QWE21', 1),
         Product('qWE21', 2),
         Product('AQS22', 3),
         Product('VCS21', 4),
         Product('QWS45', 5)
     ]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertEqual(None, client.get_total_price(2))
Example #11
0
 def test_check_for_too_big_list(self):
     products = [
         Product('PN12', 1),
         Product('PP234', 2),
         Product('PP235', 1),
         Product('AC10', 5),
         Product('AMN32', 2)
     ]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertEqual(None, client.get_total_price(2))
 def test_None(self):
     products = [
         Product('PP234', 2),
         Product('PP235', 3),
         Product('PP236', 4),
         Product('PP237', 5),
         Product('PP238', 6),
         Product('PP239', 7)
     ]
     server = MapServer(products)
     client = Client(server)
     prod = client.get_total_price(2)
     self.assertEqual(prod, None)
Example #13
0
 def test_total_price_for_exception_thrown(self):
     products = [
         Product('QWE21', 1),
         Product('qWE21', 2),
         Product('AQS22', 3),
         Product('VCS21', 4),
         Product('QWS45', 5)
     ]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         with self.assertRaises(TooManyProductsFoundError):
             entries = server.get_entries(3)
             self.assertEqual(None, client.get_total_price(3))
 def test_total_price_for_normal_execution(self):
     products = [Product('PP234', 2), Product('PP235', 3)]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertEqual(5, client.get_total_price(2))
 def test_None_If_tooMany(self):
     products = [Product('PP234', 2), Product('PP235', 3), Product('PP236', 4), Product('PP237', 5)]
     server = ListServer(products)
     client = Client(server)
     prod = client.get_total_price(2)
     self.assertEqual(prod,None)
Example #16
0
 def test_price_not_found(self):
     products = [Product('aa11', 1), Product('aa13', 3), Product('aa12', 2)]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertEqual(None, client.get_total_price(3))
 def test_None_If_not_enough(self):
     products = []
     server = MapServer(products)
     client = Client(server)
     prod = client.get_total_price(2)
     self.assertEqual(prod, None)
Example #18
0
 def test_total_price_for_empty_list(self):
     products = [Product('PP234', 2), Product('PP235', 3)]
     for server_type in server_types:
         server = server_type(products)
         client = Client(server)
         self.assertIsNone(client.get_total_price(3))