def save_work_records(self, work_records: list): """Save a list of WorkRecords to the Library""" ## Get User object from library user = self.polarion.get_user(self.user_name) for work_record in work_records: ##TODO could paralleize this as each request has to wait for connection/response to the library, meaning it takes awhile (15sec) to do a week's worth of time entry print( "Saving work record in Library. WorkItem: %s, Date:%s, TimeSpent: %s, Comment: %s" % (work_record.work_item_id, work_record.date, round_hours_for_library( work_record.time_spent), work_record.description), flush=True) ## Get WorkItemURI work_item_uri = None work_item_uri = self.polarion.get_workitem_by_id( work_record.work_item_id).uri ## Add work record to workItem temp_enum = { 'id': 'admin' } ##TODO find a good way to set this enum in clockify or lookup a default in the library project space self.polarion.add_work_record_with_comment( work_item_uri, user, work_record.date, round_hours_for_library(work_record.time_spent), temp_enum, work_record.description)
def test_rounding_for_library_Zero_Input(self): self.assertEqual("0.0h", round_hours_for_library(0))
def test_rounding_for_library_Negative_Input(self): self.assertEqual("-1.0h", round_hours_for_library(-1))
def test_rounding_for_library_Large_Input(self): self.assertEqual("234.75h", round_hours_for_library(234.68))
def test_rounding_for_library_Long_Decimal_Input(self): self.assertEqual("1.25h", round_hours_for_library(1.177777777777777777777777))
def test_rounding_for_library_Round_Up_to_zeroth_quarter(self): self.assertEqual("6.0h", round_hours_for_library(5.88))
def test_rounding_for_library_Round_Up_to_third_quarter(self): self.assertEqual("8.75h", round_hours_for_library(8.66))
def test_rounding_for_library_Round_Up(self): self.assertEqual("1.25h", round_hours_for_library(1.13))
def test_rounding_for_library_Round_Up_to_first_quarter(self): self.assertEqual("9.25h", round_hours_for_library(9.21))
def test_rounding_for_library_Round_Rown_to_third_quarter(self): self.assertEqual("0.75h", round_hours_for_library(0.8))
def test_rounding_for_library_Round_Rown_to_second_quarter(self): self.assertEqual("3.5h", round_hours_for_library(3.62))
def test_rounding_for_library_Round_Rown_to_first_quarter(self): self.assertEqual("7.25h", round_hours_for_library(7.31))
def test_rounding_for_library_Round_Down_to_zeroth_quarter(self): self.assertEqual("5.0h", round_hours_for_library(5.1))
def test_rounding_for_library_Round_Up_Borderline(self): self.assertEqual("1.25h", round_hours_for_library(1.126))
def test_rounding_for_library_Same_Number(self): self.assertEqual("1.0h", round_hours_for_library(1.0))
def test_rounding_for_library_Round_Down(self): self.assertEqual("1.0h", round_hours_for_library(1.12))
def test_rounding_for_library_Round_Up_to_second_quarter(self): self.assertEqual("4.5h", round_hours_for_library(4.45))