File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -200,12 +200,12 @@ def run_validation(self, data):
200200 # let's set zero as default value
201201 if data .get ("status_type" , None ) == "Start" and data .get (field ) == "" :
202202 data [field ] = 0
203- # missing data in accounting stop ,
203+ # missing data in accounting data ,
204204 # let's remove the empty string to
205205 # prevent the API from failing
206206 # the existing values stored in previous
207207 # interim-updates won't be changed
208- if data .get ("status_type" , None ) == "Stop " and data .get (field ) == "" :
208+ if data .get ("status_type" , None ) != "Start " and data .get (field ) == "" :
209209 del data [field ]
210210 return super ().run_validation (data )
211211
Original file line number Diff line number Diff line change @@ -603,6 +603,26 @@ def test_accounting_update_200(self):
603603 data ["terminate_cause" ] = ""
604604 self .assertAcctData (ra , data )
605605
606+ @freeze_time (START_DATE )
607+ def test_accounting_update_missing_octets (self ):
608+ self .assertEqual (RadiusAccounting .objects .count (), 0 )
609+ ra = self ._create_radius_accounting (** self ._acct_initial_data )
610+ data = self .acct_post_data
611+ data ["status_type" ] = "Interim-Update"
612+ data ["input_octets" ] = ""
613+ data ["output_octets" ] = ""
614+ data = self ._get_accounting_params (** data )
615+ response = self .post_json (data )
616+ self .assertEqual (response .status_code , 200 )
617+ self .assertIsNone (response .data )
618+ self .assertEqual (RadiusAccounting .objects .count (), 1 )
619+ ra .refresh_from_db ()
620+ self .assertEqual (ra .update_time .timetuple (), now ().timetuple ())
621+ data ["terminate_cause" ] = ""
622+ data ["input_octets" ] = 0
623+ data ["output_octets" ] = 0
624+ self .assertAcctData (ra , data )
625+
606626 @mock .patch .object (
607627 app_settings ,
608628 "CALLED_STATION_IDS" ,
You can’t perform that action at this time.
0 commit comments