Ejemplo n.º 1
0
    def test_dictify_with_relationships_includes(self, app):
        # given
        offer = Offer()
        stock = Stock()
        offer.stocks = [stock]

        # when
        stock_dict = as_dict(stock)
        offer_dict = as_dict(offer, includes=["stocks"])

        # then
        assert 'stocks' in offer_dict
        assert len(offer_dict['stocks']) == 1
        assert offer_dict['stocks'][0]['id'] == stock_dict['id']
    def test_on_datetime_list_returns_string_with_date_in_ISO_8601_list(self):
        # Given
        offer = Offer()
        stock = Stock()
        stock.offer = offer
        stock.beginningDatetime = now
        stock.endDatetime = now + timedelta(hours=3)
        offer.stocks = [stock]

        # When
        serialized_list = serialize(offer.dateRange)

        # Then
        for date in serialized_list:
            self._assert_is_in_ISO_8601_format(date)
Ejemplo n.º 3
0
    def test_should_return_soft_deleted_entities_when_option_is_given(self):
        # given
        offer = Offer(name='foo', type='bar')
        stock1 = Stock(price=10, isSoftDeleted=True)
        stock2 = Stock(price=5, isSoftDeleted=False)
        offer.stocks = [stock1, stock2]
        includes = [{
            'key': 'stocks',
            'includes': ['price'],
            'with_soft_deleted_entities': True
        }]

        # when
        offer_dict = as_dict(offer, includes=includes)

        # then
        assert len(offer_dict['stocks']) == 2