def test_get_admin_projects_count_with_no_projects(self, snapshot): #arrange user_id = 1 storage = ProjectStorageImplementation() #act response = storage.get_admin_projects_count(user_id) #assert snapshot.assert_match(response, 'projects_count')
def test_get_workflow_id_of_project(self, projects, snapshot): #arrange storage = ProjectStorageImplementation() project_id = 1 #act workflow_id = storage.get_workflow_id_of_project(project_id=project_id) #assert snapshot.assert_match(workflow_id, 'workflow_id')
def test_validate_project_id_with_invalid_id(self, projects, snapshot): #arrange storage = ProjectStorageImplementation() project_id = 100 #act project_dto = storage.validate_project_id(project_id=project_id) #assert snapshot.assert_match(project_dto, 'project_dto')
def test_get_user_projects_count(self, projects, snapshot): #arrange user_id = 2 storage = ProjectStorageImplementation() #act response = storage.get_user_projects_count(user_id) #assert snapshot.assert_match(response, 'projects_count')
def test_validate_workflow_id_with_invalid_id(self, workflows, snapshot): #arrange storage = ProjectStorageImplementation() workflow_id = 100 #act is_workflow_valid = storage.validate_workflow_id( workflow_id=workflow_id) #assert snapshot.assert_match(is_workflow_valid, 'is_workflow_valid')
def test_get_transition_mandatory_checklist(self, projects, snapshot): #arrange from .raw_inputs import update_task_state_query_dto storage = ProjectStorageImplementation() #act response = storage.get_transition_mandatory_checklist( update_task_state_query_dto) #assert snapshot.assert_match(response, 'transition_checklist_dtos')
def test_get_states_transition_details(self, projects, snapshot): #arrange from .raw_inputs import get_transition_details_query_dto storage = ProjectStorageImplementation() #act response = storage.get_states_transition_details( get_transition_details_query_dto) #assert snapshot.assert_match(response, 'transition_details_dto')
def test_get_states_transition_details_with_zero_checklist( self, projects, snapshot): #arrange from .raw_inputs\ import query_dto_with_no_checklist_for_transition storage = ProjectStorageImplementation() #act response = storage.get_states_transition_details( query_dto_with_no_checklist_for_transition) #assert snapshot.assert_match(response, 'transition_details')
def test_validate_developer_for_project_with_invalid_id( self, projects, snapshot): #arrange storage = ProjectStorageImplementation() developer_user_id = 3 project_id = 1 #act is_developer_valid = storage.validate_developer_for_project( user_id=developer_user_id, project_id=project_id) #assert snapshot.assert_match(is_developer_valid, 'is_developer_valid')
def test_get_projects_for_user_with_limit_1(self, interface_mock, projects, user_admin_dto, snapshot): #arrange user_id = 2 storage = ProjectStorageImplementation() interface_mock.get_user_dto.return_value = user_admin_dto #act user_projects_details_dtos = storage.get_projects_for_user( user_id=user_id, limit=1, offset=0) #assert snapshot.assert_match(user_projects_details_dtos, 'user_projects_details')
def test_validate_transition_with_invalid_transition( self, projects, snapshot): #arrange workflow_id = 1 from_state_id = 2 to_state_id = 1 storage = ProjectStorageImplementation() #act response = storage.validate_transition(workflow_id, from_state_id, to_state_id) #assert snapshot.assert_match(response, 'is_transition_valid')
def api_wrapper(*args, **kwargs): # ---------MOCK IMPLEMENTATION--------- user = kwargs['user'] project_id = kwargs['project_id'] task_id = kwargs['task_id'] project_storage = ProjectStorageImplementation() task_storage = TaskStorageImplementation() task_presenter = TaskPresenterImplementation() project_presenter = ProjectPresenterImplementation() interactor = GetStatesForTaskInteractor( project_storage=project_storage, task_storage=task_storage) task_state_data = { "user_id": user.user_id, "project_id": project_id, "task_id": task_id } task_states = \ interactor.get_states_for_task_based_on_current_state_wrapper( task_state_data, project_presenter, task_presenter) response_data = json.dumps(task_states) return HttpResponse(response_data, status=200)
def test_get_projects_for_admin_with_offset_gt_total_projects( self, interface_mock, projects, user_admin_dto, snapshot): #arrange user_id = 1 storage = ProjectStorageImplementation() interface_mock.get_user_dto.return_value = user_admin_dto #act admin_projects_details_dtos = storage.get_projects_for_admin( user_id=user_id, limit=2, offset=3) #assert snapshot.assert_match(admin_projects_details_dtos, 'user_projects_details')
def api_wrapper(*args, **kwargs): # ---------MOCK IMPLEMENTATION--------- user = kwargs['user'] request_data = kwargs['request_data'] project_id = kwargs['project_id'] task_id = kwargs['task_id'] to_state_id = request_data['to_state_id'] project_storage = ProjectStorageImplementation() task_storage = TaskStorageImplementation() task_presenter = TaskPresenterImplementation() project_presenter = ProjectPresenterImplementation() interactor = GetStatesTransitionDetailsInteractor( project_storage=project_storage, task_storage=task_storage) transition_details_query_dict = { "user_id": user.user_id, "project_id": project_id, "task_id": task_id, "to_state_id": to_state_id } states_transition_details = interactor\ .get_states_transition_details_wrapper(transition_details_query_dict, project_presenter, task_presenter) response_data = json.dumps(states_transition_details) return HttpResponse(response_data, status=200)
def api_wrapper(*args, **kwargs): # ---------MOCK IMPLEMENTATION--------- user = kwargs['user'] request_data = kwargs['request_data'] storage = ProjectStorageImplementation() presenter = ProjectPresenterImplementation() interactor = CreateProjectInteractor( storage=storage ) user_id = user.user_id developers = request_data.get('developers') is_developers_empty = not developers if is_developers_empty: developers = [] project_data = { "name": request_data['name'], "description": request_data['description'], "workflow_id": request_data['workflow_id'], "project_type": request_data['project_type'], "developers": developers } project_details = interactor.create_project_wrapper( user_id=user_id, project_data=project_data, presenter=presenter ) project_details['success_message'] = "Project Created Succesfully" response_data = json.dumps(project_details) return HttpResponse(response_data, status=201)
def api_wrapper(*args, **kwargs): # ---------MOCK IMPLEMENTATION--------- user = kwargs['user'] request_data = kwargs['request_data'] project_storage = ProjectStorageImplementation() task_storage = TaskStorageImplementation() task_presenter = TaskPresenterImplementation() project_presenter = ProjectPresenterImplementation() interactor = CreateTaskInteractor( project_storage=project_storage, task_storage=task_storage ) print("*"*100,"\n"*5,request_data['state_id'],"\n"*10) project_id = kwargs['project_id'] user_id = user.user_id task_data = { "project_id": project_id, "issue_type": request_data['issue_type'], "title": request_data['title'], "description": request_data['description'], "state_id": request_data['state_id'] } task_details = interactor.create_task_wrapper( user_id=user_id, task_data=task_data, project_presenter=project_presenter, task_presenter=task_presenter ) print("\n"*5,task_details,"\n"*5) response_data = json.dumps(task_details) return HttpResponse(response_data, status=201)
def test_create_project(self, interface_mock, workflows, user_admin_dto, snapshot): #arrange from project_management_portal.tests.storages.raw_inputs\ import project_details_dto user_id = 1 storage = ProjectStorageImplementation() interface_mock.get_user_dto.return_value = user_admin_dto #act project_details_dto = storage.create_project(user_id=user_id, project_dto=project_dto) #assert snapshot.assert_match(project_details_dto, 'project_details_dto')
def test_create_project_with_no_developers(self, workflows, user_admin_dto, snapshot): #arrange from .raw_inputs\ import project_details_with_no_developers_dto,\ project_with_no_developers_dto project_dto = project_with_no_developers_dto user_id = 1 storage = ProjectStorageImplementation() #act with patch.object(UserService, 'get_user_dto', return_value=user_admin_dto): project_details_dto = storage.create_project( user_id=user_id, project_dto=project_dto) #assert snapshot.assert_match(project_details_dto, 'project_details_dto')
def _convert_task_obj_to_task_details_dto(task_obj): project_utils = ProjectStorageImplementation() projec_details_dto = project_utils\ ._convert_project_object_to_project_details_dto(task_obj.project) task_details_dto = TaskDetailsDto(task_id=task_obj.id, project=projec_details_dto, issue_type=task_obj.issue_type, title=task_obj.title, assignee_id=task_obj.assignee_id, description=task_obj.description, state=task_obj.state.name) return task_details_dto
def api_wrapper(*args, **kwargs): # ---------MOCK IMPLEMENTATION--------- user = kwargs['user'] project_id = kwargs['project_id'] project_storage = ProjectStorageImplementation() task_storage = TaskStorageImplementation() task_presenter = TaskPresenterImplementation() project_presenter = ProjectPresenterImplementation() interactor = GetTasksInteractor(project_storage=project_storage, task_storage=task_storage) user_id = user.user_id tasks_details = interactor.get_tasks_wrapper( user_id=user_id, project_id=project_id, project_presenter=project_presenter, task_presenter=task_presenter) response_data = json.dumps(tasks_details) return HttpResponse(response_data, status=200)
def api_wrapper(*args, **kwargs): # ---------MOCK IMPLEMENTATION--------- user = kwargs['user'] query_params = kwargs['request_query_params'].__dict__ project_storage = ProjectStorageImplementation() project_presenter = ProjectPresenterImplementation() interactor = GetProjectsInteractor(project_storage=project_storage) user_id = user.user_id limit = query_params.get('limit', DEFAULT_LIMIT) offset = query_params.get('offset', DEFAULT_OFFSET) projects_details = interactor.get_projects_wrapper( user_id=user_id, offset=offset, limit=limit, project_presenter=project_presenter) response_data = json.dumps(projects_details) return HttpResponse(response_data, status=200)
def api_wrapper(*args, **kwargs): # ---------MOCK IMPLEMENTATION--------- user = kwargs['user'] request_data = kwargs['request_data'] project_storage = ProjectStorageImplementation() task_storage = TaskStorageImplementation() task_presenter = TaskPresenterImplementation() project_presenter = ProjectPresenterImplementation() interactor = TaskStateTransitionInteractor(project_storage=project_storage, task_storage=task_storage) project_id = kwargs['project_id'] task_id = kwargs['task_id'] checklist = request_data['checklist'] user_id = user.user_id update_task_state_data = { "user_id": user_id, "project_id": project_id, "task_id": task_id, "from_state_id": request_data.get('from_state_id'), "to_state_id": request_data.get('to_state_id'), "checklist": checklist } task_details = interactor.update_task_state_wrapper( update_task_state_data, project_presenter=project_presenter, task_presenter=task_presenter) response_data = json.dumps(task_details) return HttpResponse(response_data, status=201)