コード例 #1
0
    def test_offer_get_all(self):
        o1 = api.offer_create(test_offer_2)
        o2 = api.offer_create(test_offer_3)
        res = api.offer_get_all({})

        self.assertEqual(2, res.count())
        self.assertEqual((o1.to_dict(), o2.to_dict()),
                         (res[0].to_dict(), res[1].to_dict()))
コード例 #2
0
    def test_offer_get_all_time_filter(self):
        o1 = api.offer_create(test_offer_1)
        o2 = api.offer_create(test_offer_2)
        api.offer_create(test_offer_3)
        api.offer_create(test_offer_4)
        api.offer_create(test_offer_5)
        res = api.offer_get_all({
            'start_time':
            o1.start_time + datetime.timedelta(days=26),
            'end_time':
            o1.end_time + datetime.timedelta(days=-1),
        })

        self.assertEqual(2, res.count())
        self.assertEqual((o1.to_dict(), o2.to_dict()),
                         (res[0].to_dict(), res[1].to_dict()))
コード例 #3
0
    def test_offer_get_all_lessee_filter(self, mock_gppit):
        mock_gppit.return_value = ['12345', '67890']

        o1 = api.offer_create(test_offer_1)
        o2 = api.offer_create(test_offer_2)
        o3 = api.offer_create(test_offer_3)
        api.offer_create(test_offer_4)
        o5 = api.offer_create(test_offer_5)
        res = api.offer_get_all({'lessee_id': '12345'})

        mock_gppit.assert_called_once_with('12345')
        self.assertEqual(4, res.count())
        self.assertEqual(
            (o1.to_dict(), o2.to_dict(), o3.to_dict(), o5.to_dict()),
            (res[0].to_dict(), res[1].to_dict(), res[2].to_dict(),
             res[3].to_dict()))
コード例 #4
0
    def test_offer_get_all_time_filter_within(self):
        o1 = api.offer_create(test_offer_1)
        o2 = api.offer_create(test_offer_2)
        o3 = api.offer_create(test_offer_3)
        o4 = api.offer_create(test_offer_4)
        api.offer_create(test_offer_5)
        res = api.offer_get_all({
            'start_time':
            o1.end_time + datetime.timedelta(days=-2),
            'end_time':
            o2.end_time + datetime.timedelta(days=1),
            'time_filter_type':
            'within'
        })

        self.assertEqual(4, res.count())
        self.assertEqual(
            (o1.to_dict(), o2.to_dict(), o3.to_dict(), o4.to_dict()),
            (res[0].to_dict(), res[1].to_dict(), res[2].to_dict(),
             res[3].to_dict()))
コード例 #5
0
 def test_offer_create(self):
     offer = api.offer_create(test_offer_1)
     o = api.offer_get_all({}).all()
     assert len(o) == 1
     assert o[0].to_dict() == offer.to_dict()