def it_creates_a_fee(self, db_session):
        fee = create_fee()
        assert Fee.query.count() == 1

        fee_from_db = Fee.query.filter(Fee.id == fee.id).first()

        assert fee == fee_from_db
Esempio n. 2
0
    def it_returns_correct_event_type_with_fees(self, client, sample_event_type, db_session):
        fees = [
            create_fee(event_type_id=str(sample_event_type.id), valid_from='2017-03-01'),
            create_fee(event_type_id=str(sample_event_type.id), fee=10, conc_fee=7, valid_from='2017-02-01')
        ]

        response = client.get(
            url_for('event_type.get_event_type_by_id', event_type_id=str(sample_event_type.id))
        )
        assert response.status_code == 200

        json_resp = json.loads(response.get_data(as_text=True))
        assert json_resp['id'] == str(sample_event_type.id)

        for i, fee in enumerate(fees):
            assert json_resp['fees'][i]['fee'] == fee.fee
            assert json_resp['fees'][i]['conc_fee'] == fee.conc_fee
Esempio n. 3
0
    def it_gets_an_event_type_with_fees_ordered(self, db, db_session,
                                                sample_event_type):
        fees = [
            create_fee(event_type_id=str(sample_event_type.id),
                       valid_from='2017-01-01'),
            create_fee(event_type_id=str(sample_event_type.id),
                       fee=8,
                       conc_fee=6,
                       valid_from='2017-02-01'),
            create_fee(event_type_id=str(sample_event_type.id),
                       fee=10,
                       conc_fee=7)
        ]

        event_type = dao_get_event_type_by_id(str(sample_event_type.id))
        assert event_type.id == sample_event_type.id
        assert len(event_type.fees) == 3
        assert sorted(fees,
                      key=lambda f: getattr(f, 'valid_from'),
                      reverse=True) == event_type.fees
Esempio n. 4
0
    def it_shows_fee_json_on_serialize(self, db, db_session):
        fee = create_fee(fee=5, conc_fee=3)

        assert fee.serialize() == {
            'id': str(fee.id),
            'event_type_id': str(fee.event_type_id),
            'fee': fee.fee,
            'conc_fee': fee.conc_fee,
            'multi_day_fee': fee.multi_day_fee,
            'multi_day_conc_fee': fee.multi_day_conc_fee,
            'valid_from': fee.valid_from.isoformat()
        }
    def it_gets_a_fee_by_id(self, db, db_session, sample_fee):
        fee = create_fee(fee=100, conc_fee=80)

        fetched_fee = dao_get_fee_by_id(fee.id)
        assert fetched_fee == fee
    def it_gets_all_fees(self, db, db_session, sample_fee):
        fees = [create_fee(fee=100, conc_fee=80), sample_fee]

        fees_from_db = dao_get_fees()
        assert Fee.query.count() == 2
        assert set(fees) == set(fees_from_db)
Esempio n. 7
0
def sample_fee(db, sample_event_type):
    return create_fee(fee=5, conc_fee=3, event_type_id=sample_event_type.id)