def setUp(self) -> None: self.company = create_company() self.not_existing_company_pk = 1000000 self.company_detail_url = reverse( 'companies:detail', kwargs={'pk': self.company.account.id}) self.invalid_company_detail_url = reverse( 'companies:detail', kwargs={'pk': self.not_existing_company_pk})
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})
def setUp(self) -> None: self.company = create_company() self.robot = create_robot(company=self.company) self.service = create_robot_service(robot=self.robot) 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 })
def setUp(self) -> None: self.company = create_company() self.free_robot = create_robot(company=self.company, status=Robot.Status.FREE) self.busy_robot = create_robot(company=self.company, status=Robot.Status.BUSY) self.unavailable_robot = create_robot(company=self.company, status=Robot.Status.UNAVAILABLE) self.valid_service = { 'arrival_datetime': fake.future_datetime(tzinfo=timezone.get_current_timezone()), 'robot': self.free_robot.id, 'status': fake.random_element(Service.Status.values), 'type': fake.random_element(Service.Type.values) } self.busy_robot_service = { **self.valid_service, 'robot': self.busy_robot.id, 'status': Service.Status.NOT_STARTED } self.invalid_busy_robot_service = { **self.busy_robot_service, 'status': fake.random_element([ s for s in Service.Status.values if s != Service.Status.NOT_STARTED ]) } self.unavailable_robot_service = { **self.valid_service, 'robot': self.unavailable_robot.id } self.free_robot_service_list_url = reverse('companies:service-list', kwargs={ 'company_pk': self.company.account.id, 'robot_pk': self.free_robot.id }) self.busy_robot_service_list_url = reverse('companies:service-list', kwargs={ 'company_pk': self.company.account.id, 'robot_pk': self.busy_robot.id }) self.unavailable_robot_service_list_url = reverse( 'companies:service-list', kwargs={ 'company_pk': self.company.account.id, 'robot_pk': self.unavailable_robot.id })
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 })
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.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 setUp(self) -> None: self.company = create_company() self.company_detail_url = reverse( 'companies:detail', kwargs={'pk': self.company.account.id})
def setUp(self) -> None: self.company = create_company() self.robot = create_robot(company=self.company) self.robot_detail_url = reverse('companies:robot-detail', kwargs={'company_pk': self.company.account.id, 'robot_pk': self.robot.id})