Beispiel #1
0
    def test_actions_get_should_be_return_products(self, product_mock):
        # Arrange
        id = str(uuid4())
        product_mock.name = 'Nescau'
        product_mock.cost_values = 10.00
        product_mock.unit_box = 5
        product_mock.weight_unit = 0.500
        product_mock.validity = "2021-12-19"
        product_mock.sku = '09ub124ibbi413'
        product_mock.description = 'Descrição...'
        product_mock.category_line_id = id
        product_mock.supplier_id = id
        product_mock.on_create = datetime.datetime.now().strftime(
            "%Y-%m-%d %H:%M")
        product_mock.on_update = datetime.datetime.now().strftime(
            "%Y-%m-%d %H:%M")

        query = Mock()
        query.all = MagicMock(return_value=[product_mock])
        product_mock.query = query

        # Action
        products = get_products()

        # Assertions
        self.assertTrue(product_mock.query.all.called)
        self.assertEqual(len(products), 1)
Beispiel #2
0
def import_route_by_supplier():
    try:
        file = request.files['data_file']
    except:
        raise NoFileError()
    stream = io.StringIO(file.stream.read().decode("utf-8"))
    insert_data(stream, 'sku', validate_by_supplier, [], [], [])
    return jsonify([product.serialize() for product in get_products()]), 200
Beispiel #3
0
def export():
    products_list = get_products()
    csv_file = create_csv_file([product.serialize() for product in products_list])
    return send_csv_file(csv_file, 'Products')
Beispiel #4
0
def get() -> Tuple[Any, int]:
    return jsonify([products.serialize_final_cost(get_percentages(products.category_line_id))
                    for products in get_products()]), 200