def testSetUp(wareHouse): wareHouse.append(Product("Wasser1", "100", "1")) wareHouse.append(Product("Wasser2", "200", "1")) wareHouse.append(Product("Wasser3", "300", "1")) wareHouse.append(Product("Wasser4", "400", "1")) wareHouse.append(Product("Wasser5", "500", "3")) wareHouse.append(Product("Wasser6", "600", "5")) wareHouse.append(Product("Wasser7", "700", "7")) wareHouse.append(Product("Wasser8", "800", "9")) wareHouse.append(Product("Wasser9", "900", "100")) wareHouse.append(Product("Wasser10", "1000", "20"))
def get_product(id_sku): product_1 = Product('321321', 'broca 4mm') product_2 = Product('123123', 'broca 5mm') product_3 = Product('987654', 'broca 6mm') product_repo.add(product_1) product_repo.add(product_2) product_repo.add(product_3) result = product_repo.get(id_sku) return f'Product detail: {result}'
def setUp(wareHouse): '''Initializes the Warehouse''' wareHouse.append(Product("Wasser1", "100", "1")) wareHouse.append(Product("Wasser2", "200", "1")) wareHouse.append(Product("Wasser3", "300", "1")) wareHouse.append(Product("Wasser4", "400", "1")) wareHouse.append(Product("Wasser5", "500", "3")) wareHouse.append(Product("Wasser6", "600", "5")) wareHouse.append(Product("Wasser7", "700", "7")) wareHouse.append(Product("Wasser8", "800", "9")) wareHouse.append(Product("Wasser9", "900", "100")) wareHouse.append(Product("Wasser10", "1000", "20"))
def get_products(): product_1 = Product('321321', 'broca 4mm') product_2 = Product('123123', 'broca 5mm') product_3 = Product('987654', 'broca 6mm') product_repo.add(product_1) product_repo.add(product_2) product_repo.add(product_3) filters = request.get_json() result = product_repo.find_all(filters) return f'Product detail: {result}'
def update_product(id_sku): product_dict = request.get_json() product = Product.from_dict(product_dict) product_repo.update(id_sku, product) result = product_repo.get(product.id_sku) return f'Product created!: {result}'
def get_nth_product(self, number): product = self.driver.find_element( self.NTH_PRODUCT[0], self.NTH_PRODUCT[1].format(str(number))) name = self.__get_product_name(product) current_price = Decimal(self.__get_current_price(product)) return Product(name=name, current_price=current_price)
def CreateProduct(self, request, context): print("got called for createProduct") product = Product(code=str(uuid.uuid4()), productName=request.productName, quantity=request.quantity, price=request.price, imageLink=request.imageLink, description=request.description) product = self.product_service.add(product=product) return self.ToProtoProduct(product)
def test_add_product(): wareHouse = [] testSetUp(wareHouse) lenght = len(wareHouse) addProduct(wareHouse, Product("Wasser11", 300, 2)) assert len(wareHouse) > lenght for item in wareHouse: assert type(item.get_product_price()) is int assert type(item.get_product_quantity()) is int assert item.get_product_price() >= 0 assert item.get_product_quantity() >= 0
def test_json(self): j = '{"fruits": ["apple", "banana", "orange"]}' data = json.loads(j) self.assertEqual(data['fruits'][0], 'apple') j1 = '{"fruits": {"1":"apple", "2":"banana", "3":"orange"}}' dat2 = json.loads(j1) self.assertEqual(dat2['fruits']['1'], 'apple') j2 = '{"category_name": "Холодные напитки",' \ '"photo_origin": "/upload/pos_cdb_67169/menu/product_1540043162_6.jpg",' \ '"price": {"1": "7500"},' \ '"product_id": "6",' \ '"product_name": "Лимонад",' \ '"spots": [{"spot_id": "1","price": "7500","profit": "6500","visible": "1"}]' \ '}' p = Product.deserialize(json.loads(j2)) self.assertEqual(p.product_name, u'Лимонад') self.assertEqual(p.price, '7500')
def uiAddProduct(wareHouse, productName, productQuantity, productPrice): '''Adds a new product with (productName, productQuantity, productPrice) to wareHouse repository''' addProduct(wareHouse, Product(productName, productPrice, productQuantity))
def read_product(self, path: str, flag: str): attrs_list = FileReader.read_lines(path, flag, False) for attrs in attrs_list: product = Product(attrs[0], attrs[1], attrs[2]) self.products[product.product_id] = product
# following try to create a new directory in the current path # if directory exists then it throw and exception complaining that dir already exists. # os.mkdir("zeedir") # The Following command (getcwd) get the current working directory # Also you can use chdir command to change the current direcitry. # For removing a directory just use : rmdir currentPath = os.getcwd() print("Current Directory is :: ", currentPath) # os.rmdir("zeedir") u = User('Touraj', 38) u.printuser() p = Product('lot', 100) p.printproduct() e = Employee("Martin", 1000) e.displayEmployee() # you can also use getattr like a getter in java name = getattr(e, 'name') salary = getattr(e, 'salary') print(name) print(salary) # Built-In Class Attributes print(e.__class__) print(e.__dict__) print(e.__str__)
def get_product_for_account(product_id, account, token): # type: (str, str) -> Product r = requests.get( 'https://{}.joinposter.com/api/menu.getProduct?token={}&product_id={}'. format(account, token, product_id)) return Product.deserialize(r.json().get('response'))
def test_product(): product = Product(1, "Daniel", 100) assert product.getID() == 1 assert product.getName() == "Daniel" assert product.getPrice() == 100 product.setId(2) product.setName("Alex") product.setPrice(10) assert product.getID() == 2 assert product.getName() == "Alex" assert product.getPrice() == 10
def delete_product(): product_dict = request.get_json() product = Product.from_dict(product_dict) product_repo.delete(product.id_sku) return f'Product deleted!'