コード例 #1
0
def test_sort_level_price_dict():
    myoffer = offer.Offer()
    assert myoffer.level_price_dict is None
    myoffer.level_price_dict = TEST_DICT
    keys = list(myoffer.level_price_dict.keys())
    assert myoffer._is_level_price_dict_sorted()
    assert myoffer.level_price_dict[keys[
        0]] == "101", "Level Price Dict values should not be assigned to wrong key"
コード例 #2
0
def test_init_args_out_of_order_fails():
    with raises(TypeError):
        offer.Offer(TEST_DICT, 1)
コード例 #3
0
def test_init_no_args():
    myoffer = offer.Offer()
    assert myoffer.id == 0
    assert myoffer.level_price_dict is None
コード例 #4
0
def test_init_named_args_out_of_order():
    myoffer = offer.Offer(level_price_dict=TEST_DICT, id=1)
    assert myoffer.id == 1
    assert myoffer.level_price_dict == TEST_DICT
コード例 #5
0
def test_init_level_price_dict_missing():
    myoffer = offer.Offer(1)
    assert myoffer.level_price_dict is None
コード例 #6
0
def test_init_string_id():
    myoffer = offer.Offer("1")
    assert myoffer.id == 1
コード例 #7
0
def test_init_int_id():
    myoffer = offer.Offer(1)
    assert myoffer.id == 1
コード例 #8
0
def test_level_price_dict_tuple_fails():
    myoffer = offer.Offer(1, {(1, 2), (3, 4)})
    assert myoffer.level_price_dict is None
コード例 #9
0
import urmarketscraper.offer as offer
from pytest import raises

TEST_DICT = {2: "456", 3: "789", 1: "123", 4: "101"}
FULL_OFFER = offer.Offer(1, TEST_DICT)


# Happy Path - No Args Init
def test_init_no_args():
    myoffer = offer.Offer()
    assert myoffer.id == 0
    assert myoffer.level_price_dict is None


# Happy Path - Init Int Id
def test_init_int_id():
    myoffer = offer.Offer(1)
    assert myoffer.id == 1


# Happy Path - Init String Id
def test_init_string_id():
    myoffer = offer.Offer("1")
    assert myoffer.id == 1


# Happy Path - Level Price Dict Sorted on Init
def test_init_level_price_dict_sorted():
    keys = list(FULL_OFFER.level_price_dict.keys())
    print(keys)
    assert FULL_OFFER._is_level_price_dict_sorted(