Пример #1
0
def test_get_all_subscriptions_wrong_value(controller: Controller):
    """Check that Controller raises exception in case of empty owner field"""
    with pytest.raises(SubscriptionException) as exc:
        result = controller.get_subscriptions_list("")
        assert result == subscriptions_obj_list
    expected_exc_msg = "Field length should be more than one"
    assert expected_exc_msg == str(exc.value)
Пример #2
0
def test_get_all_subscriptions(controller: Controller, owner: str):
    """Check that Controller returned correct list of Subscription objects:
        - No _id specified in each subscription
        - type is not dict, but Subscription
        - start_date field type is not datetime, but date
    """
    result = controller.get_subscriptions_list(owner)
    assert result == subscriptions_obj_list
Пример #3
0
def test_get_all_subscriptions_wrong_type(controller: Controller, owner):
    """Check that Controller raises exception in case of invalid owner field type"""
    with pytest.raises(SubscriptionException) as exc:
        result = controller.get_subscriptions_list(owner)
        assert result == subscriptions_obj_list
    expected_exc_msg = WRONG_TYPE_MSG.format(
        expected=str, recieved_type=type(owner), field=owner
    )
    assert expected_exc_msg == str(exc.value)
Пример #4
0
def test_get_next_payment_date(controller: Controller):
    """Check that client can get next_payment_date attribute for subscriptions in subscription list"""
    subscriptions_list = controller.get_subscriptions_list()
    assert type(subscriptions_list[0]) == Subscription
    for subs in subscriptions_list:
        assert type(subs.next_payment_date) is date