Example #1
0
def test_remove():
    global sql_delete_order, sql_delete_product, sql_delete_user
    product_recordService = Product_recordService()
    result = product_recordService.remove(product_record)
    assert result

    result = db_request(commit=True, sql=sql_delete_product)
    result = db_request(commit=True, sql=sql_delete_order)
    result = db_request(commit=True, sql=sql_delete_user)
def test_remove():
    global sql_delete_currency, sql_delete_product
    priceService = PriceService()
    result = priceService.remove(price)
    assert result

    sql_delete_currency = sql_delete_currency.format(
        type_currency_id=type_currency_id)
    result = db_request(commit=True, sql=sql_delete_currency)

    sql_delete_product = sql_delete_product.format(product_id=product_id)
    result = db_request(commit=True, sql=sql_delete_product)
def test_remove():
    global sql_delete
    p_orderService = P_orderService()
    result = p_orderService.remove(p_order1)
    assert result

    sql_delete = sql_delete.format(id1=id1)
    result = db_request(commit=True, sql=sql_delete)
def test_remove():
    global sql_delete
    friend_recordService = Friend_recordService()
    result = friend_recordService.remove(friend_record1)
    assert result

    sql_delete = sql_delete.format(id1=id1, id2=id2)
    result = db_request(commit=True, sql=sql_delete)
Example #5
0
from tests.property import ProductRecordProperty

from main.util import db_request

#create test data
#product
sql_insert_product = '''INSERT INTO product (name, descriptions, left_in_stock)
                        VALUES ('name_test1', 'descriptions_test1', 3);'''

sql_select_product = '''SELECT id FROM product 
                         WHERE (name = 'name_test1' AND 
                         descriptions = 'descriptions_test1') ;'''

sql_delete_product = '''DELETE FROM product WHERE id = '{product_id}';'''

db_request(commit=True, sql=sql_insert_product)
result = db_request(commit=True, sql=sql_select_product)
product_id = result[0][0]

sql_delete_product = sql_delete_product.format(product_id=product_id)
#user
sql_insert_user = '''INSERT INTO p_user (firstname, surname, sex, age)
                        VALUES ('firstname_test1', 'surname_test1', 'sex', '50');'''

sql_select_user = '''SELECT id FROM p_user 
                     WHERE firstname = 'firstname_test1' AND 
                           surname = 'surname_test1';'''

sql_delete_user = '''DELETE FROM p_user WHERE id = '{user_id}';'''

db_request(commit=True, sql=sql_insert_user)
from project.main.service.p_orderService import P_orderService, P_order
from tests.property import OrderProperty

from main.util import db_request

sql_insert = '''INSERT INTO p_user (firstname, surname, sex, age)
                      VALUES ('firstname_test1', 'surname_test1', 'sex', '50');'''

sql_select = '''SELECT id FROM p_user 
                WHERE (firstname = 'firstname_test1' AND 
                       surname = 'surname_test1') ;'''

sql_delete = '''DELETE FROM p_user WHERE id = '{id1}';'''

#create test users
db_request(commit=True, sql=sql_insert)
result = db_request(commit=True, sql=sql_select)
id1 = result[0][0]
#base data
p_order1 = P_order()


def test_add():
    OrderProperty.setter(p_order1, id1)

    p_orderService = P_orderService()
    result = p_orderService.add(p_order1)

    assert result

sql_insert_user = '''INSERT INTO type_currency (name)
                         VALUES ('name_test1');'''

sql_select_product = '''SELECT id FROM product 
                         WHERE (name = 'name_test1' AND 
                         descriptions = 'descriptions_test1') ;'''

sql_select_currency = '''SELECT id FROM type_currency 
                         WHERE name = 'name_test1';'''

sql_delete_product = '''DELETE FROM product WHERE id = '{product_id}';'''

sql_delete_currency = '''DELETE FROM type_currency WHERE id = '{type_currency_id}';'''

#create test data
db_request(commit=True, sql=sql_insert_product)
result = db_request(commit=True, sql=sql_select_product)
product_id = result[0][0]

db_request(commit=True, sql=sql_insert_currency)
result = db_request(commit=True, sql=sql_select_currency)
type_currency_id = result[0][0]

#base data
price = Price()


def test_add():
    PriceProperty.setter(price, product_id, type_currency_id)

    priceService = PriceService()