Exemplo n.º 1
0
 def list(self) -> List[Product]:
     result = self._entries
     return [Product.from_dict(entry) for entry in result]
Exemplo n.º 2
0
 def create(self, code, name, price) -> Product:
     adict = {"code": code, "name": name, "price": price}
     product_entity = Product.from_dict(adict)
     self._entries.append(adict)
     return product_entity
Exemplo n.º 3
0
 def find_by_code(self, code):
     for entry in self._entries:
         if entry["code"] == code:
             return Product.from_dict(entry)
Exemplo n.º 4
0
    def test_products_equality(self):
        adict = {"code": "001", "name": "Lizard", "price": 25.99}
        product1 = Product.from_dict(adict)
        product2 = Product.from_dict(adict)

        self.assertEqual(product1, product2)
Exemplo n.º 5
0
 def test_product_create_from_dict(self):
     adict = {"code": "001", "name": "Lizard", "price": 25.99}
     product = Product.from_dict(adict)
     self.assertEqual(product.code, "001")
     self.assertEqual(product.name, "Lizard")
     self.assertEqual(product.price, 25.99)
 def test_create_product(self):
     adict = {"code": "001", "name": "Lizard", "price": 25.99}
     test_product = self.repo.create(**adict)
     self.assertEqual(test_product, Product.from_dict(adict))