def setUp(self) -> None:
        self.freight = create_freight(need_transfer=True)
        self.new_delivery_service = create_robot_service(
            type=Service.Type.DELIVERY)

        not_valid_value = [1, 2, 3, 4]
        not_valid_status = fake.sentence(2)

        self.valid_partial_data = {'name': fake.sentence(1)}
        self.invalid_partial_data = {'name': not_valid_value}

        self.valid_data = {
            'name': fake.sentence(1),
            'status': self.freight.status,
            'transfer': {
                'delivery_service': self.new_delivery_service.id,
                'reception_service':
                self.freight.transfer.reception_service.id,
            },
        }

        self.invalid_data = {
            'name': fake.sentence(1),
            'status': not_valid_status,
            'transfer': {
                'delivery_service': self.freight.transfer.delivery_service.id,
                'reception_service':
                self.freight.transfer.reception_service.id,
            },
        }

        self.freight_detail_url = reverse('freights:detail',
                                          kwargs={'pk': self.freight.id})
Example #2
0
    def setUp(self) -> None:
        self.company = create_company()
        self.robot = create_robot(company=self.company)

        not_valid_status = fake.sentence(1)
        not_valid_type = fake.sentence(2)

        self.valid_partial_data = {
            'status': fake.random_element([s for s in Robot.Status.values if s != self.robot.status])
        }
        self.invalid_partial_data = {
            'status': not_valid_status
        }

        self.valid_data = {
            'model': self.robot.model,
            'type': self.robot.type,
            'company': self.company.account.id,
            'status': self.robot.status
        }

        self.invalid_data = {
            'model': self.robot.model,
            'type': not_valid_type,
            'company': self.company.account.id,
            'status': not_valid_status
        }

        self.robot_detail_url = reverse('companies:robot-detail', kwargs={'company_pk': self.company.account.id,
                                                                          'robot_pk': self.robot.id})
Example #3
0
    def setUp(self) -> None:
        self.valid_device = {
            'name': fake.sentence(1),
            'unit': fake.random_element(Device.Unit.values),
            'prefix': fake.random_element(Device.Prefix.values),
            **{k: v for k, v in zip(['min_value', 'max_value'],
                                    sorted([fake.pyfloat(right_digits=2), fake.pyfloat(right_digits=2)]))}
        }

        self.invalid_device = {
            **self.valid_device,
            'unit': fake.sentence(1)
        }
        self.device_list_url = reverse('devices:list')
 def setUp(self) -> None:
     self.company_account = create_account()
     self.valid_company = {
         'account': self.company_account.id,
         'name': fake.sentence(1),
         'type': fake.random_element(Company.Type.values)
     }
     not_existing_account = 10000000
     self.invalid_company = {
         'account': not_existing_account,
         'name': fake.sentence(1),
         'type': fake.random_element(Company.Type.values)
     }
     self.company_list_url = reverse('companies:list')
Example #5
0
    def setUp(self) -> None:
        self.company = create_company()
        self.valid_robot = {
            'model': fake.sentence(2),
            'type': fake.random_element(Robot.Type.values),
            'company': self.company.account.id,
            'status': fake.random_element(Robot.Status.values)
        }
        not_valid_type = fake.sentence(1)
        self.invalid_robot = {
            'model': fake.sentence(2),
            'type': not_valid_type,
            'company': self.company.account.id,
            'status': fake.random_element(Robot.Status.values)
        }

        self.robot_list_url = reverse('companies:robot-list', kwargs={'pk': self.company.account.id})
 def setUp(self) -> None:
     self.delivery_service = create_robot_service(
         type=Service.Type.DELIVERY)
     self.reception_service = create_robot_service(
         type=Service.Type.RECEPTION)
     self.valid_freight = {
         'name': fake.sentence(1),
         'status': fake.random_element(Freight.Status.values),
         'transfer': {
             'delivery_service': self.delivery_service.id,
             'reception_service': self.reception_service.id
         },
     }
     not_existing_transfer = 10000000
     self.invalid_freight = {
         'name': fake.sentence(1),
         'status': fake.random_element(Freight.Status.values),
         'transfer': not_existing_transfer
     }
     self.freight_list_url = reverse('freights:list')
Example #7
0
def create_company(**fields):
    fake_company_fields = {
        'name': fake.sentence(1),
        'type': fake.random_element(Company.Type.values)
    }

    if not fields.get('account'):
        fields['account'] = create_account()

    for field, value in fake_company_fields.items():
        if field not in fields:
            fields[field] = value

    return Company.objects.create(**fields)
    def setUp(self) -> None:
        self.company = create_company()

        not_valid_value = [1, 2, 3, 4]
        not_valid_type = fake.sentence(2)

        self.valid_partial_data = {'name': fake.sentence(1)}
        self.invalid_partial_data = {'name': not_valid_value}

        self.valid_data = {
            'account': self.company.account.id,
            'name': fake.sentence(1),
            'type': fake.random_element(Company.Type.values),
        }

        self.invalid_data = {
            'account': self.company.account.id,
            'name': not_valid_value,
            'type': not_valid_type,
        }

        self.company_detail_url = reverse(
            'companies:detail', kwargs={'pk': self.company.account.id})
def create_freight(need_transfer=False, **fields):
    fake_freight_fields = {
        'name': fake.sentence(1),
        'status': fake.random_element(Freight.Status.values),
        'is_damaged': False,
    }

    if need_transfer and not fields.get('transfer'):
        fields['transfer'] = create_transfer()

    for field, value in fake_freight_fields.items():
        if field not in fields:
            fields[field] = value

    return Freight.objects.create(**fields)
Example #10
0
def create_robot(**fields):
    fake_robot_fields = {
        'model': fake.sentence(1),
        'type': fake.random_element(Robot.Type.values),
        'status': fake.random_element(Robot.Status.values)
    }

    if not fields.get('company', None):
        fields['company'] = create_company()

    for field, fake_value in fake_robot_fields.items():
        if field not in fields:
            fields[field] = fake_value

    return Robot.objects.create(**fields)
    def setUp(self) -> None:
        self.company = create_company()
        self.robot = create_robot(company=self.company,
                                  status=Robot.Status.FREE)
        self.unavailable_robot = create_robot(company=self.company,
                                              status=Robot.Status.UNAVAILABLE)
        self.service = create_robot_service(robot=self.robot)

        not_valid_status = fake.sentence(1)
        not_valid_datetime = 'not valid datetime'

        self.valid_partial_data = {
            'status':
            fake.random_element(
                [s for s in Service.Status.values if s != self.robot.status])
        }
        self.invalid_partial_data = {'status': not_valid_status}
        self.invalid_partial_data_with_robot = {
            'robot': self.unavailable_robot.id
        }

        self.valid_data = {
            'arrival_datetime':
            self.service.arrival_datetime,
            'robot':
            self.robot.id,
            'status':
            fake.random_element(
                [s for s in Service.Status.values if s != self.robot.status]),
            'type':
            self.service.type
        }

        self.invalid_data = {
            'arrival_datetime': not_valid_datetime,
            'robot': self.robot.id,
            'status': self.service.status,
            'type': self.service.type
        }

        self.service_detail_url = reverse('companies:service-detail',
                                          kwargs={
                                              'company_pk':
                                              self.company.account.id,
                                              'robot_pk': self.robot.id,
                                              'service_pk': self.service.id
                                          })
Example #12
0
def create_device(**fields):
    fake_device_fields = {
        'name': fake.sentence(1),
        'unit': fake.random_element(Device.Unit.values),
        'prefix': fake.random_element(Device.Prefix.values),
        **{
            k: v
            for k, v in zip(['min_value', 'max_value'],
                            sorted([
                                fake.pyfloat(right_digits=2),
                                fake.pyfloat(right_digits=2)
                            ]))
        }
    }

    for field, value in fake_device_fields.items():
        if field not in fields:
            fields[field] = value

    return Device.objects.create(**fields)
Example #13
0
    def setUp(self) -> None:
        self.device = create_device()

        self.valid_partial_data = {
            'unit': fake.random_element([value for value in Device.Unit.values if value != self.device.unit]),
        }
        self.invalid_partial_data = {
            'unit': fake.sentence(1)
        }
        self.valid_data = {
            'name': self.device.name,
            'unit': self.device.unit,
            'prefix': self.device.prefix,
            'min_value': fake.pyfloat(right_digits=2, max_value=floor(self.device.max_value)),
            'max_value': self.device.max_value,
        }
        self.invalid_data = {
            **self.valid_data,
            'min_value': self.valid_data['max_value'],
            'max_value': self.valid_data['min_value'],
        }

        self.device_detail_url = reverse('devices:detail', kwargs={'pk': self.device.id})