Exemplo n.º 1
0
def test_add_currency(currency_params):
    currency: CurrencyOutputFields = CurrenciesDAL.add_currency(
        *currency_params)
    assert currency.id == 1
    with create_session() as session:
        currency = session.query(Currency).filter(Currency.id == 1).first()
        assert currency.selling_price == currency_params[1]
        assert currency.purchasing_price == currency_params[2]
Exemplo n.º 2
0
 def post(self) -> Any:
     try:
         validated_json = validate_request_json(request.data,
                                                currencies_input_fields)
         return (
             marshal(
                 CurrenciesDAL.add_currency(**validated_json),
                 currency_output_fields,
             ),
             HTTPStatus.CREATED,
         )
     except (ValidationException, CurrenciesDALException) as e:
         return marshal({'message': e},
                        error_fields), HTTPStatus.BAD_REQUEST
Exemplo n.º 3
0
def test_add_currency_with_invalid_price(currency_params):
    with pytest.raises(CurrenciesDALException):
        CurrenciesDAL.add_currency('test', Decimal(0), Decimal(0))
Exemplo n.º 4
0
def test_add_currency_that_already_exists(currency_params):
    with pytest.raises(CurrenciesDALException):
        CurrenciesDAL.add_currency(*currency_params)
Exemplo n.º 5
0
def _add_currency(currency_params):
    CurrenciesDAL.add_currency(*currency_params)