Example #1
0
class JobTests(AbstractEntityApiTestCase):

    def setUp(self):
        self.station = Station(name='MyTestStation')
        self.station.save()
        self.box = Box(station=self.station, address='My address str. 4')
        self.box.save()
        self.stand = Stand(box=self.box, name='MyStand')
        self.stand.save()
        self.service = Service(name='TestService',
                               min_duration=datetime.timedelta(minutes=30),
                               max_duration=datetime.timedelta(minutes=30),
                               min_cost=500,
                               max_cost=1000)
        self.service.save()

    def tearDown(self):
        self.station.delete()
        self.box.delete()
        self.stand.delete()
        self.service.delete()

    def _create_job(self, client, services, date_time):
        data = {
            'client': client,
            'selected_services': services,
            'date': date_time
        }
        return self._call_rest('post', 'job/', data)

    def test_job_creation(self):
        selected_services = [1, 2]
        date = '2016-01-11T03:00:07.451Z'
        client = {
            'phone': '8 999 000 0000',
            'car': {'model': 'Impreza', 'manufacturer': 'Subaru'}
        }

        job = self._create_job(client, selected_services, date)
        self.assertEqual(job.get('client'), 1)
        self.assertEqual(job.get('stand'), 1)
        self.assertEqual(job.get('date_time'), '2016-01-11T03:00:07.451000Z')

    def test_job_not_assigned_to_one_time(self):
        selected_services = [1]
        date1 = '2016-01-11T03:00:07.451Z'
        client = {
            'phone': '8-100-000-0000',
            'car': {'model': 'Impreza', 'manufacturer': 'Subaru'}
        }
        date2 = '2016-01-11T03:00:00.000Z'
        date3 = '2016-01-11T02:59:00.000Z'

        job = self._create_job(client, selected_services, date1)
        self.assertEqual(job['stand'], self.stand.id)
        job = self._create_job(client, selected_services, date2)
        self.assertEqual(job['detail'], 'No free stands for accept job')
        job = self._create_job(client, selected_services, date3)
        log.warn(job)
Example #2
0
 def setUp(self):
     self.station = Station(name='MyTestStation')
     self.station.save()
     self.box = Box(station=self.station, address='My address str. 4')
     self.box.save()
     self.stand = Stand(box=self.box, name='MyStand')
     self.stand.save()
     self.service = Service(name='TestService',
                            min_duration=datetime.timedelta(minutes=30),
                            max_duration=datetime.timedelta(minutes=30),
                            min_cost=500,
                            max_cost=1000)
     self.service.save()
Example #3
0
 def setUp(self):
     self.station = Station(name='MyTestStation')
     self.station.save()
     self.box = Box(station=self.station, address='My address str. 4')
     self.box.save()
     self.stand = Stand(box=self.box, name='MyStand')
     self.stand.save()
     self.service = Service(name='TestService',
                            min_duration=datetime.timedelta(minutes=30),
                            max_duration=datetime.timedelta(minutes=30),
                            min_cost=500,
                            max_cost=1000)
     self.service.save()
Example #4
0
class JobTests(AbstractEntityApiTestCase):
    def setUp(self):
        self.station = Station(name='MyTestStation')
        self.station.save()
        self.box = Box(station=self.station, address='My address str. 4')
        self.box.save()
        self.stand = Stand(box=self.box, name='MyStand')
        self.stand.save()
        self.service = Service(name='TestService',
                               min_duration=datetime.timedelta(minutes=30),
                               max_duration=datetime.timedelta(minutes=30),
                               min_cost=500,
                               max_cost=1000)
        self.service.save()

    def tearDown(self):
        self.station.delete()
        self.box.delete()
        self.stand.delete()
        self.service.delete()

    def _create_job(self, client, services, date_time):
        data = {
            'client': client,
            'selected_services': services,
            'date': date_time
        }
        return self._call_rest('post', 'job/', data)

    def test_job_creation(self):
        selected_services = [1, 2]
        date = '2016-01-11T03:00:07.451Z'
        client = {
            'phone': '8 999 000 0000',
            'car': {
                'model': 'Impreza',
                'manufacturer': 'Subaru'
            }
        }

        job = self._create_job(client, selected_services, date)
        self.assertEqual(job.get('client'), 1)
        self.assertEqual(job.get('stand'), 1)
        self.assertEqual(job.get('date_time'), '2016-01-11T03:00:07.451000Z')

    def test_job_not_assigned_to_one_time(self):
        selected_services = [1]
        date1 = '2016-01-11T03:00:07.451Z'
        client = {
            'phone': '8-100-000-0000',
            'car': {
                'model': 'Impreza',
                'manufacturer': 'Subaru'
            }
        }
        date2 = '2016-01-11T03:00:00.000Z'
        date3 = '2016-01-11T02:59:00.000Z'

        job = self._create_job(client, selected_services, date1)
        self.assertEqual(job['stand'], self.stand.id)
        job = self._create_job(client, selected_services, date2)
        self.assertEqual(job['detail'], 'No free stands for accept job')
        job = self._create_job(client, selected_services, date3)
        log.warn(job)