-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14649 from transcom/B-21446-TIO-bulk-assignment-be
B 21446 tio bulk assignment be
- Loading branch information
Showing
6 changed files
with
717 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1655,7 +1655,7 @@ func (suite *HandlerSuite) TestGetServicesCounselingQueueHandler() { | |
} | ||
|
||
func (suite *HandlerSuite) TestGetBulkAssignmentDataHandler() { | ||
suite.Run("returns an unauthorized error when an attempt is made by a non supervisor", func() { | ||
suite.Run("SC - returns an unauthorized error when an attempt is made by a non supervisor", func() { | ||
officeUser := factory.BuildOfficeUserWithPrivileges(suite.DB(), []factory.Customization{ | ||
{ | ||
Model: models.OfficeUser{ | ||
|
@@ -1689,7 +1689,7 @@ func (suite *HandlerSuite) TestGetBulkAssignmentDataHandler() { | |
suite.IsNotErrResponse(response) | ||
suite.IsType(&queues.GetBulkAssignmentDataUnauthorized{}, response) | ||
}) | ||
suite.Run("returns properly formatted bulk assignment data", func() { | ||
suite.Run("SC - returns properly formatted bulk assignment data", func() { | ||
transportationOffice := factory.BuildTransportationOffice(suite.DB(), nil, nil) | ||
|
||
officeUser := factory.BuildOfficeUserWithPrivileges(suite.DB(), []factory.Customization{ | ||
|
@@ -1892,4 +1892,118 @@ func (suite *HandlerSuite) TestGetBulkAssignmentDataHandler() { | |
suite.Len(payload.AvailableOfficeUsers, 1) | ||
suite.Len(payload.BulkAssignmentMoveIDs, 1) | ||
}) | ||
|
||
suite.Run("TIO - returns an unauthorized error when an attempt is made by a non supervisor", func() { | ||
officeUser := factory.BuildOfficeUserWithPrivileges(suite.DB(), []factory.Customization{ | ||
{ | ||
Model: models.OfficeUser{ | ||
Email: "[email protected]", | ||
}, | ||
}, | ||
{ | ||
Model: models.User{ | ||
Roles: []roles.Role{ | ||
{ | ||
RoleType: roles.RoleTypeTIO, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil) | ||
|
||
request := httptest.NewRequest("GET", "/queues/bulk-assignment", nil) | ||
request = suite.AuthenticateOfficeRequest(request, officeUser) | ||
params := queues.GetBulkAssignmentDataParams{ | ||
HTTPRequest: request, | ||
QueueType: models.StringPointer("PAYMENT_REQUEST"), | ||
} | ||
handlerConfig := suite.HandlerConfig() | ||
handler := GetBulkAssignmentDataHandler{ | ||
handlerConfig, | ||
officeusercreator.NewOfficeUserFetcherPop(), | ||
movefetcher.NewMoveFetcherBulkAssignment(), | ||
} | ||
response := handler.Handle(params) | ||
suite.IsNotErrResponse(response) | ||
suite.IsType(&queues.GetBulkAssignmentDataUnauthorized{}, response) | ||
}) | ||
suite.Run("TIO - returns properly formatted bulk assignment data", func() { | ||
transportationOffice := factory.BuildTransportationOffice(suite.DB(), nil, nil) | ||
|
||
officeUser := factory.BuildOfficeUserWithPrivileges(suite.DB(), []factory.Customization{ | ||
{ | ||
Model: models.OfficeUser{ | ||
Email: "[email protected]", | ||
Active: true, | ||
}, | ||
}, | ||
{ | ||
Model: transportationOffice, | ||
LinkOnly: true, | ||
Type: &factory.TransportationOffices.CounselingOffice, | ||
}, | ||
{ | ||
Model: models.User{ | ||
Privileges: []models.Privilege{ | ||
{ | ||
PrivilegeType: models.PrivilegeTypeSupervisor, | ||
}, | ||
}, | ||
Roles: []roles.Role{ | ||
{ | ||
RoleType: roles.RoleTypeTIO, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil) | ||
|
||
// payment request to appear in the return | ||
move := factory.BuildMoveWithShipment(suite.DB(), []factory.Customization{ | ||
{ | ||
Model: models.Move{ | ||
Status: models.MoveStatusAPPROVALSREQUESTED, | ||
}, | ||
}, | ||
{ | ||
Model: transportationOffice, | ||
LinkOnly: true, | ||
Type: &factory.TransportationOffices.CounselingOffice, | ||
}, | ||
}, nil) | ||
factory.BuildPaymentRequest(suite.DB(), []factory.Customization{ | ||
{ | ||
Model: models.PaymentRequest{ | ||
ID: uuid.Must(uuid.NewV4()), | ||
IsFinal: false, | ||
Status: models.PaymentRequestStatusPending, | ||
RejectionReason: nil, | ||
}, | ||
}, | ||
{ | ||
Model: move, | ||
LinkOnly: true, | ||
}, | ||
}, nil) | ||
|
||
request := httptest.NewRequest("GET", "/queues/bulk-assignment", nil) | ||
request = suite.AuthenticateOfficeRequest(request, officeUser) | ||
params := queues.GetBulkAssignmentDataParams{ | ||
HTTPRequest: request, | ||
QueueType: models.StringPointer("PAYMENT_REQUEST"), | ||
} | ||
handlerConfig := suite.HandlerConfig() | ||
handler := GetBulkAssignmentDataHandler{ | ||
handlerConfig, | ||
officeusercreator.NewOfficeUserFetcherPop(), | ||
movefetcher.NewMoveFetcherBulkAssignment(), | ||
} | ||
response := handler.Handle(params) | ||
suite.IsNotErrResponse(response) | ||
suite.IsType(&queues.GetBulkAssignmentDataOK{}, response) | ||
payload := response.(*queues.GetBulkAssignmentDataOK).Payload | ||
suite.NoError(payload.Validate(strfmt.Default)) | ||
suite.Len(payload.AvailableOfficeUsers, 1) | ||
suite.Len(payload.BulkAssignmentMoveIDs, 1) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.