Beispiel #1
0
 def GET(self, code=None):
     """Lista os produtos cadastradas no sistema."""
     #Se nenhum código de produto foi informado
     if code == None:
         #Capturo a lista de produtos e faço um dump dos dicionários da lista
         return json.dumps(
             [p.__dict__ for p in Product().selectAllProducts()])
     else:
         #Se um código de produto foi informado, capturo o objeto e faço um dump de seu dicionario
         return json.dumps(Product().selectProduct(code).__dict__)
Beispiel #2
0
    def test_setupProductHxListSchouldReturnListWithTwoProductHX(self):
        productList = []
        product = Product('thee grey',4.1,14,15,19)
        product2= Product('thee aardbei',2,16,17,12)
        
        productList.append(product)
        productList.append(product2)
        measureInventory = MeasureInventory.MeasureInventory(productList)     

        productHXList = measureInventory.setupProductHxList()
        self.assertEqual(len(productHXList), 2)
Beispiel #3
0
    def DELETE(self, code=None):
        """Apaga um produto do sistema."""

        #Se o código informado não for nulo,
        if code != None:

            #Testo selecionar a categoria
            product = Product().selectProduct(code)

            #Se ela realmente existir
            if product != None:
                #Deleto-a
                product.deleteProduct()
Beispiel #4
0
 def test_InitSchouldCreateMeasureInventoryObjectWithProductList(self):
     productList = []
     product = Product('thee grey','2','14','15','19')
     productList.append(product)
     measureInventory = MeasureInventory.MeasureInventory(productList)
     
     self.assertEqual(measureInventory.products, productList)
    def fetch_all(self):

        model_obj_list = []

        # 根据参数拼接SQL,执行
        sql = """ select * from tb """

        # 获取数据库结果
        result = [
            {
                'nid': '1',
                'name': 'seven',
                'rrp': 10,
                'selling_price': 9
            },
        ]

        # 循环所有的结果,格式化为模型
        for item in result:
            model_obj_list.append(
                Product(nid=item['nid'],
                        name=item['name'],
                        price=Price(rrp=item['rrp'],
                                    selling_price=item['selling_price'])))
        return model_obj_list
Beispiel #6
0
 def test_calculateTotalAverageInGramsSchouldReturnCorrectTotalWeight(self):
     productList = []
     product = Product('thee grey','2','14','15','19')
     MeasurementList=[29,30,29,30,31,31,30,29,31,30]
     productList.append(product)
     measureInventory = MeasureInventory.MeasureInventory(productList)
     
     totalWeight= measureInventory.calculateTotalAverageInGrams(MeasurementList)
     self.assertEqual(totalWeight, 30)
Beispiel #7
0
    def test_calculateUnitsSchouldReturnTenUnits(self):
        productList = []
        product = Product('thee grey',4.1,'14','15',19)
        
        productList.append(product)
        measureInventory = MeasureInventory.MeasureInventory(productList)     

        Units= measureInventory.calculateUnits(59,product.container,product.weight)
        self.assertEqual(Units,9)
 def getProduct(self, name):
     try:
         self.__conn = Conn()
         flag, product = self.__conn._selectEach("name", name, table="product")
         product = Product(*product)
         return flag, product
     except Exception as e:
         print(e)
         return flag
Beispiel #9
0
    def test_reject_outliersSchouldReturnListWithoutOutliers(self):
        productList = []
        product = Product('thee grey',4.1,14,15,19)
        measurementList=[29,30,1029,30,31,31,1,29,31,30]      
        productList.append(product)
        
        measureInventory = MeasureInventory.MeasureInventory(productList)     

        result = measureInventory.reject_outliers(measurementList)
        self.assertEqual(len(result), 8)
Beispiel #10
0
 def test_setGPIOofProductSchouldReturnCorrectDoutAndPD_SCK(self):
     productList = []
     product = Product('thee grey','2','14','15','19')
     
     productList.append(product)
     measureInventory = MeasureInventory.MeasureInventory(productList)
     
     hx= measureInventory.setGPIOofProduct(product)
     self.assertEqual(hx.DOUT, 14)
     self.assertEqual(hx.PD_SCK, 15)
Beispiel #11
0
    def PUT(self, strJson):
        """Inclui ou atualiza """

        if strJson != None:
            product = Product()
            product.__dict__ = json.loads(strJson)

            #Se é um novo registro, adiciono. Caso contrário, atualizo.
            if product.isNew():
                product.insertProduct()
            else:
                product.updateProduct()
    def MapEnvironmentVariables(enviromentList):
        productList = []
        for enviromentVariables in enviromentList:
            print(enviromentVariables)
            variable = enviromentVariables.split(':')
            product = Product(variable[0], float(variable[1]), variable[2],
                              variable[3], float(variable[4]))
            productList.append(product)
            print(len(enviromentList))

        return productList
Beispiel #13
0
    def test_ReadMultipleMeasurementsSchouldReturnListWithLenghtFive(self, mock_method):
        productList = []
        product = Product('thee grey',2,'14','15','19')
        
        productList.append(product)
        measureInventory = MeasureInventory.MeasureInventory(productList)
        hx= measureInventory.setGPIOofProduct(product)
        

        MeasurementList = measureInventory.ReadMultipleMeasurements(hx,5)
        self.assertEqual(len(MeasurementList), 5)
Beispiel #14
0
def create_product():
    name = request.json['name']
    description = request.json['description']
    price = float(request.json['price'])
    barcode = request.json['barcode']
    promotion = request.json['promotion']

    new_product = Product(name, description, price, barcode, promotion)
    db.session.add(new_product)
    db.session.commit()

    return product_schema.jsonify(new_product)
Beispiel #15
0
    def test_setupProductHxListSchouldReturnCorrectAttributeValues(self):
        productList = []
        product = Product('thee grey',4.1,14,15,19)
        
        productList.append(product)
        measureInventory = MeasureInventory.MeasureInventory(productList)     

        productHXList = measureInventory.setupProductHxList()
        self.assertEqual(productHXList[0].product.name, 'thee grey')
        self.assertEqual(productHXList[0].product.container, 19)
        self.assertEqual(productHXList[0].product.DT, 14)
        self.assertEqual(productHXList[0].product.SCK, 15)
Beispiel #16
0
    def addProduct(self, product_name, brand, price_cad, product_description,
                   category, sub_cat):
        """Inserts a new product into the Product collection"""
        prod = Product(product_name, brand, price_cad, product_description,
                       category, sub_cat)

        return prod_collection.insert_one({
            "_id": prod.id,
            "Name": prod.name,
            "Brand": prod.brand,
            "Price": prod.price,
            "Description:": prod.description,
            "Sub-Category": prod.subCategory,
            "Category": prod.category
        })
 def __setProduct(self, product):
     item = Product(*product)
     self.__products.append(item)
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
from Model.Order import Order
from Model.Product import Product

# laver et product
prod = Product(1, "hans", 123, 2, 1)
#laver en order
order = Order(1, "12-12-2000", prod, 3)

print(order.getOrderId())

p = Product(2, "otto", 123, 2, 1)
p.setName("Ole")
print(p.getName())