def setUp(self) -> None: self.freight = create_freight(need_transfer=True) self.rule = create_rule(freight=self.freight) self.state = create_state(rule=self.rule) invalid_value = fake.pyfloat(right_digits=2, min_value=ceil( self.rule.device.max_value)) self.valid_partial_data = { 'value': fake.pyfloat(right_digits=2, min_value=ceil(self.rule.min_value), max_value=floor(self.rule.max_value)) } self.invalid_partial_data = {'value': invalid_value} self.valid_data = { 'value': fake.pyfloat(right_digits=2, min_value=ceil(self.rule.min_value), max_value=floor(self.rule.max_value)), 'rule': self.rule.id } self.invalid_data = {'value': invalid_value, 'rule': self.rule.id} self.state_detail_url = reverse('freights:state-detail', kwargs={ 'freight_pk': self.freight.id, 'rule_pk': self.rule.id, 'state_pk': self.state.id })
def setUp(self) -> None: self.device = create_device() self.freight = create_freight(need_transfer=True) self.rule = create_rule(device=self.device, freight=self.freight) not_valid_max_value = fake.pyfloat(right_digits=2, min_value=ceil(self.device.max_value)) self.valid_partial_data = { 'max_value': fake.pyfloat(right_digits=2, min_value=ceil(self.rule.min_value), max_value=floor(self.device.max_value)) } self.invalid_partial_data = { 'max_value': not_valid_max_value } self.valid_data = { 'coefficient': self.rule.coefficient, 'possible_deviation': fake.pyfloat(right_digits=2, min_value=0, max_value=10), 'time_interval': self.rule.time_interval, 'device': self.device.id, 'freight': self.freight.id, 'min_value': self.rule.min_value, 'max_value': self.rule.max_value, } self.invalid_data = { **self.valid_data, 'min_value': self.valid_data['max_value'], 'max_value': self.valid_data['min_value'], } self.rule_detail_url = reverse('freights:rule-detail', kwargs={'freight_pk': self.freight.id, 'rule_pk': self.rule.id})
def setUp(self) -> None: self.freight = create_freight(need_transfer=True) self.rule = create_rule(freight=self.freight) self.not_existing_rule_pk = 1000000 self.rule_detail_url = reverse('freights:rule-detail', kwargs={'freight_pk': self.freight.id, 'rule_pk': self.rule.id}) self.invalid_rule_detail_url = reverse('freights:rule-detail', kwargs={'freight_pk': self.not_existing_rule_pk, 'rule_pk': self.rule.id})
def setUp(self) -> None: self.freight = create_freight() self.rule = create_rule(freight=self.freight) for i in range(20): create_state(limit_values=(self.rule.min_value, self.rule.max_value), rule=self.rule) self.health_check_url = reverse('freights:check-health', kwargs={'pk': self.freight.id})
def setUp(self) -> None: self.freight = create_freight(need_transfer=True) self.rule = create_rule(freight=self.freight) self.state = create_state(rule=self.rule) self.state_detail_url = reverse('freights:state-detail', kwargs={ 'freight_pk': self.freight.id, 'rule_pk': self.rule.id, 'state_pk': self.state.id })
def create_state(limit_values=None, **fields): if not limit_values: min_value, max_value = sorted( [fake.pyfloat(right_digits=2), fake.pyfloat(right_digits=2)]) else: min_value, max_value = limit_values fake_state_fields = { 'value': fake.pyfloat(right_digits=2, min_value=floor(min_value), max_value=ceil(max_value)), } if not fields.get('rule'): fields['rule'] = create_rule() for field, value in fake_state_fields.items(): if field not in fields: fields[field] = value return State.objects.create(**fields)
def setUp(self) -> None: self.freight = create_freight(need_transfer=True) self.rule = create_rule(freight=self.freight) self.valid_state = { 'value': fake.pyfloat(right_digits=2, min_value=floor(self.rule.min_value), max_value=ceil(self.rule.max_value)), 'rule': self.rule.id, } invalid_value = fake.pyfloat(right_digits=2, min_value=ceil( self.rule.device.max_value)) self.invalid_state = { 'value': invalid_value, 'rule': self.rule.id, } self.state_list_url = reverse('freights:state-list', kwargs={ 'freight_pk': self.freight.id, 'rule_pk': self.rule.id })