Пример #1
0
 def test_offer_get_conflict_times(self):
     o1 = api.offer_create(test_offer_1)
     self.assertEqual(api.offer_get_conflict_times(o1), [])
     test_contract_3['offer_uuid'] = o1.uuid
     api.contract_create(test_contract_3)
     self.assertEqual(api.offer_get_conflict_times(o1),
                      [(now + datetime.timedelta(days=50),
                        now + datetime.timedelta(days=60))])
Пример #2
0
 def test_contract_get_all(self):
     o1 = api.offer_create(test_offer_2)
     test_contract_4['offer_uuid'] = o1.uuid
     o2 = api.offer_create(test_offer_3)
     test_contract_5['offer_uuid'] = o2.uuid
     c1 = api.contract_create(test_contract_4)
     c2 = api.contract_create(test_contract_5)
     res = api.contract_get_all({})
     self.assertEqual((c1.to_dict(), c2.to_dict()),
                      (res[0].to_dict(), res[1].to_dict()))
Пример #3
0
 def test_offer_get_first_availability(self):
     o1 = api.offer_create(test_offer_1)
     self.assertEqual(
         api.offer_get_first_availability(
             o1.uuid,
             o1.start_time,
         ), None)
     test_contract_3['offer_uuid'] = o1.uuid
     api.contract_create(test_contract_3)
     self.assertEqual(
         api.offer_get_first_availability(o1.uuid, o1.start_time),
         (now + datetime.timedelta(days=50), ))
Пример #4
0
 def test_contract_create(db):
     o1 = api.offer_create(test_offer_2)
     test_contract_4['offer_uuid'] = o1.uuid
     c1 = api.contract_create(test_contract_4)
     c2 = api.contract_get_all({}).all()
     assert len(c2) == 1
     assert c2[0].to_dict() == c1.to_dict()
Пример #5
0
 def test_contract_update_invalid_time(self):
     o1 = api.offer_create(test_offer_3)
     test_contract_4['offer_uuid'] = o1.uuid
     c1 = api.contract_create(test_contract_4)
     values = {
         'start_time': now + datetime.timedelta(days=101),
         'end_time': now
     }
     self.assertRaises(e.InvalidTimeRange, api.contract_update, c1.uuid,
                       values)
Пример #6
0
 def test_contract_update(self):
     o1 = api.offer_create(test_offer_2)
     test_contract_4['offer_uuid'] = o1.uuid
     c1 = api.contract_create(test_contract_4)
     values = {
         'start_time': test_contract_5['start_time'],
         'end_time': test_contract_5['end_time']
     }
     api.contract_update(c1.uuid, values)
     c1 = api.contract_get_by_uuid(c1.uuid)
     self.assertEqual(test_contract_5['start_time'], c1.start_time)
     self.assertEqual(test_contract_5['end_time'], c1.end_time)
Пример #7
0
    def test_contract_get_by_name(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)
        test_contract_1['offer_uuid'] = o1.uuid
        test_contract_2['offer_uuid'] = o2.uuid
        test_contract_3['offer_uuid'] = o3.uuid
        test_contract_4['offer_uuid'] = o4.uuid
        c1 = api.contract_create(test_contract_1)
        c2 = api.contract_create(test_contract_2)
        c3 = api.contract_create(test_contract_3)
        api.contract_create(test_contract_4)
        res = api.contract_get_by_name('c1')
        assert len(res) == 3
        self.assertEqual(c1.uuid, res[0].uuid)
        self.assertEqual(c1.project_id, res[0].project_id)

        self.assertEqual(c2.uuid, res[1].uuid)
        self.assertEqual(c2.project_id, res[1].project_id)

        self.assertEqual(c3.uuid, res[2].uuid)
        self.assertEqual(c3.project_id, res[2].project_id)
Пример #8
0
    def test_offer_verify_availability(self):
        offer = api.offer_create(test_offer_1)

        test_contract_1['offer_uuid'] = offer.uuid
        test_contract_2['offer_uuid'] = offer.uuid
        test_contract_3['offer_uuid'] = offer.uuid

        api.contract_create(test_contract_1)
        api.contract_create(test_contract_2)
        api.contract_create(test_contract_3)

        start = now + datetime.timedelta(days=35)
        end = now + datetime.timedelta(days=40)
        api.offer_verify_availability(offer, start, end)

        start = now + datetime.timedelta(days=5)
        end = now + datetime.timedelta(days=10)
        api.offer_verify_availability(offer, start, end)

        start = now
        end = now + datetime.timedelta(days=10)
        api.offer_verify_availability(offer, start, end)

        start = now + datetime.timedelta(days=90)
        end = now + datetime.timedelta(days=100)
        api.offer_verify_availability(offer, start, end)

        start = now + datetime.timedelta(days=60)
        end = now + datetime.timedelta(days=100)
        api.offer_verify_availability(offer, start, end)

        start = now + datetime.timedelta(days=30)
        end = now + datetime.timedelta(days=50)
        api.offer_verify_availability(offer, start, end)

        start = now + datetime.timedelta(days=15)
        end = now + datetime.timedelta(days=16)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now + datetime.timedelta(days=45)
        end = now + datetime.timedelta(days=55)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now + datetime.timedelta(days=55)
        end = now + datetime.timedelta(days=65)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now + datetime.timedelta(days=50)
        end = now + datetime.timedelta(days=65)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now + datetime.timedelta(days=45)
        end = now + datetime.timedelta(days=60)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now + datetime.timedelta(days=90)
        end = now + datetime.timedelta(days=105)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now + datetime.timedelta(days=100)
        end = now + datetime.timedelta(days=105)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now + datetime.timedelta(days=105)
        end = now + datetime.timedelta(days=110)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now - datetime.timedelta(days=1)
        end = now + datetime.timedelta(days=5)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now - datetime.timedelta(days=1)
        end = now
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now - datetime.timedelta(days=10)
        end = now - datetime.timedelta(days=5)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        start = now + datetime.timedelta(days=45)
        end = now + datetime.timedelta(days=55)
        self.assertRaises(e.OfferNoTimeAvailabilities,
                          api.offer_verify_availability, offer, start, end)

        test_contract_4['offer_uuid'] = offer.uuid
        api.contract_create(test_contract_4)
        start = now + datetime.timedelta(days=86)
        end = now + datetime.timedelta(days=87)
        api.offer_verify_availability(offer, start, end)
Пример #9
0
 def test_contract_destroy(self):
     o1 = api.offer_create(test_offer_2)
     test_contract_4['offer_uuid'] = o1.uuid
     c1 = api.contract_create(test_contract_4)
     api.contract_destroy(c1.uuid)
     self.assertEqual(api.contract_get_by_uuid('contract_4'), None)
Пример #10
0
 def test_contract_get_by_uuid(self):
     o1 = api.offer_create(test_offer_2)
     test_contract_4['offer_uuid'] = o1.uuid
     c1 = api.contract_create(test_contract_4)
     res = api.contract_get_by_uuid(c1.uuid)
     self.assertEqual(c1.uuid, res.uuid)