def init_position_and_unit(session):
    medium = get_medium_by_name(TEST_MEDIUM)

    size = add_size(200, 50)

    add_unit(TEST_UNIT, 300, medium, size)
    add_position(TEST_POSITION, medium, size)
def init_position_and_unit(session):
    medium = get_medium_by_name(TEST_MEDIUM)

    size = add_size(200, 50)

    add_unit(TEST_UNIT, 300, medium, size)
    add_position(TEST_POSITION, medium, size)
示例#3
0
def test_schedule(session):
    unit1 = add_unit('unit1', 800)
    unit2 = add_unit('unit2', 700)
    position1 = add_position('position1')
    position2 = add_position('position2')
    position1.units = [unit1, unit2]
    position2.units = [unit1, unit2]

    assert unit1.estimate_num == 800
    assert unit2.estimate_num == 700
    assert position1.estimate_num == unit1.estimate_num + unit2.estimate_num
    assert position2.estimate_num == unit1.estimate_num + unit2.estimate_num

    item1 = add_item(position=position1)
    item2 = add_item(position=position2)

    _date = date.today()

    assert position1.schedule_num(_date) == 0
    assert position2.schedule_num(_date) == 0

    assert unit1.schedule_num(_date) == 0
    assert unit2.schedule_num(_date) == 0

    assert unit1.retain_num(_date) == 800
    assert unit2.retain_num(_date) == 700

    assert position1.retain_num(_date) == 1500
    assert position2.retain_num(_date) == 1500

    AdSchedule.add(item1, 500, _date)
    AdSchedule.add(item2, 100, _date)

    user = User.get_by_email('*****@*****.**')
    AdItem.update_items_with_action([item1], ITEM_STATUS_ACTION_PRE_ORDER,
                                    user)
    AdItem.update_items_with_action([item2], ITEM_STATUS_ACTION_PRE_ORDER,
                                    user)

    assert position1.schedule_num(_date) == 500
    assert position2.schedule_num(_date) == 100

    assert unit1.schedule_num(_date) == 320
    assert unit2.schedule_num(_date) == 280

    assert unit1.retain_num(_date) == 480
    assert unit2.retain_num(_date) == 420

    assert position1.retain_num(_date) == 900
    assert position2.retain_num(_date) == 900
示例#4
0
def test_schedule(session):
    unit1 = add_unit('unit1', 800)
    unit2 = add_unit('unit2', 700)
    position1 = add_position('position1')
    position2 = add_position('position2')
    position1.units = [unit1, unit2]
    position2.units = [unit1, unit2]

    assert unit1.estimate_num == 800
    assert unit2.estimate_num == 700
    assert position1.estimate_num == unit1.estimate_num + unit2.estimate_num
    assert position2.estimate_num == unit1.estimate_num + unit2.estimate_num

    item1 = add_item(position=position1)
    item2 = add_item(position=position2)

    _date = date.today()

    assert position1.schedule_num(_date) == 0
    assert position2.schedule_num(_date) == 0

    assert unit1.schedule_num(_date) == 0
    assert unit2.schedule_num(_date) == 0

    assert unit1.retain_num(_date) == 800
    assert unit2.retain_num(_date) == 700

    assert position1.retain_num(_date) == 1500
    assert position2.retain_num(_date) == 1500

    AdSchedule.add(item1, 500, _date)
    AdSchedule.add(item2, 100, _date)

    user = User.get_by_email('*****@*****.**')
    AdItem.update_items_with_action([item1], ITEM_STATUS_ACTION_PRE_ORDER, user)
    AdItem.update_items_with_action([item2], ITEM_STATUS_ACTION_PRE_ORDER, user)

    assert position1.schedule_num(_date) == 500
    assert position2.schedule_num(_date) == 100

    assert unit1.schedule_num(_date) == 320
    assert unit2.schedule_num(_date) == 280

    assert unit1.retain_num(_date) == 480
    assert unit2.retain_num(_date) == 420

    assert position1.retain_num(_date) == 900
    assert position2.retain_num(_date) == 900
示例#5
0
def test_position(session):
    position = add_position('testposition')

    position2 = AdPosition.get(position.id)
    assert position2.name == 'testposition'

    unit = add_unit('testunit', 300)
    assert len(position.units) == 0
    position.units = [unit]

    position3 = AdPosition.get(position.id)
    assert unit in position3.units
    assert position3 in unit.positions
示例#6
0
def init_position_and_unit(session):
    medium = get_medium_by_name(TEST_MEDIUM)
    add_unit(TEST_UNIT, 300, medium)
    add_position(TEST_POSITION, medium)
示例#7
0
def test_unit_delivery(session):
    unit = add_unit('testunit', 300)
    date = datetime.date.today()
    assert unit.get_monitor_num(date) == 0
    unit.set_monitor_num(date, 500)
    assert unit.get_monitor_num(date) == 500
示例#8
0
def test_unit(session):
    unit = add_unit('testunit', 300)

    unit2 = AdUnit.get(unit.id)
    assert unit2.name == 'testunit'
    assert unit2.estimate_num == 300
def init_extra_unit_with_same_size(session):
    add_unit('extra_unit_1', 300, None, add_size(200, 50))
def init_extra_unit_with_same_medium(session):
    medium = get_medium_by_name(TEST_MEDIUM)

    add_unit('extra_unit', 300, medium)
def init_one_postion(session):
    unit = add_unit(TEST_UNIT, 800)
    position = add_position('test_position')
    position.units = [unit]
def init_extra_unit_with_same_size(session):
    add_unit('extra_unit_1', 300, None, add_size(200, 50))
def init_extra_unit_with_same_medium(session):
    medium = get_medium_by_name(TEST_MEDIUM)

    add_unit('extra_unit', 300, medium)
示例#14
0
def init_position_and_unit(session):
    medium = get_medium_by_name(TEST_MEDIUM)
    add_unit(TEST_UNIT, 300, medium)
    add_position(TEST_POSITION, medium)
示例#15
0
def init_one_postion(session):
    unit = add_unit(TEST_UNIT, 800)
    position = add_position('test_position')
    position.units = [unit]