Beispiel #1
0
    def _():

        my_pipeline = Pipeline()

        DB.session.add(my_pipeline)

        DB.session.commit()

        my_pipeline_id = my_pipeline.pipeline_id

        my_pipeline.match_table_data = match_table_dict

        @it('it accepts good data', skip=True)
        def _():
            nonlocal my_pipeline_id
            nonlocal my_pipeline
            DB.session.add(my_pipeline)
            print(my_pipeline)
            request_body = {'pipelineID': str(my_pipeline_id)}

            expected_response = {
                # "timestamp": "",
                "pipelineID": str(my_pipeline_id),
                "matchTable": match_table_dict
            }

            resp = application.post_json('/match-table', request_body)

            expect(resp.status_int).to(equal(200))

            expect(resp.json['matchTable']).to(equal(match_table_dict))
Beispiel #2
0
    def _():

        new_pipeline = Pipeline(
            user_token=uuid.uuid4(),
            file_name='test',
            file_format='test',
            file_text='test',
            preview={"hello": "world"}
        )

        DB.session.add(new_pipeline)
        DB.session.commit()

        my_pipeline_id = new_pipeline.pipeline_id


        @it('it accepts good data', skip=True)
        def _():
            request_body = {"pipelineID": str(my_pipeline_id)}
            expected_body = {
                "pipelineID": str(my_pipeline_id),
                # "preview": {
                #     "hello": "world"
                # }
            }
            resp = application.post_json('/preview', request_body)

            expect(resp.status_int).to(equal(200))
            
            expect(resp.json).to(have_keys(expected_body))
Beispiel #3
0
    def post(self):
        req = request.get_json()
        pipeline_id = RequestHandler.get_pipeline_id(req, True)
        _ = Pipeline.get_pipeline_from_id(pipeline_id)

        score, explanation = Pipeline.calculate_score(pipeline_id)

        resp = {
            c.PIPELINE_ID: str(pipeline_id),
            c.TIMESTAMP: str(datetime.datetime.now()),
            "score": str(score),
            "explanation": str(explanation)
        }

        response = ResponseHandler.create_response(resp, 200)
        return response
Beispiel #4
0
    def _():

        my_pipeline = Pipeline()

        DB.session.add(my_pipeline)

        DB.session.commit()

        my_pipeline_id = my_pipeline.pipeline_id

        request_body = {
            "pipelineID": str(my_pipeline_id),
            "matchTableSelections": match_table_selections
        }

        expected_response = {
            # "timestamp": "",
            "pipelineID": str(my_pipeline_id)
        }

        resp = application.post_json('/user-actions', request_body)

        expect(resp.status_int).to(equal(200))

        expect(my_pipeline.match_table_selections).to(
            equal(match_table_selections))
Beispiel #5
0
    def post(self):
        req = request.get_json()
        pipeline_id = RequestHandler.get_pipeline_id(req, True)
        _ = Pipeline.get_pipeline_from_id(pipeline_id)

        framework_recommendations = get_framework_recommendations(pipeline_id)

        response = ResponseHandler.create_response(framework_recommendations, 200)
        return response
Beispiel #6
0
    def post(self):
        req = request.get_json()
        pipeline_id = RequestHandler.get_pipeline_id(req, True)
        threshold = RequestHandler.get_threshold(req, False)
        frameworks = Pipeline.get_frameworks_from_pipeline_id(pipeline_id)

        match_table_data = get_match_table(pipeline_id, frameworks, threshold)
        response = ResponseHandler.create_response(match_table_data, 200)
        return response
Beispiel #7
0
    def post(self):
        req = request.get_json()
        pipeline_id = RequestHandler.get_pipeline_id(req, True)
        _ = Pipeline.get_pipeline_from_id(pipeline_id)

        preview_data = get_preview(pipeline_id)
        resp_data = self.create_response_data(pipeline_id, preview_data, req)
        response = ResponseHandler.create_response(resp_data, 200)
        return response
Beispiel #8
0
    def post(self):
        req = request.get_json()
        pipeline_id = RequestHandler.get_pipeline_id(req, True)
        pipeline = Pipeline.get_pipeline_from_id(pipeline_id)

        self.extract_and_save_to_pipeline(req, pipeline)

        resp_data = self.create_response_data(pipeline)
        response = self.make_response(resp_data)
        return response
Beispiel #9
0
    def post(self):
        req = request.get_json()
        pipeline_id = RequestHandler.get_pipeline_id(req, True)
        pipeline = Pipeline.get_pipeline_from_id(pipeline_id)

        match_table_selections = RequestHandler.get_match_table_selections(
            req,
            True
        )
        
        self.set_match_table_selections(pipeline, match_table_selections)
        
        response_data = self.make_response_data(pipeline_id, pipeline, match_table_selections)
        response = ResponseHandler.create_response(response_data, 200)
        return response
    def post(self):
        req = request.get_json()

        pipeline_id = RequestHandler.get_pipeline_id(req, True)        
        pipeline = Pipeline.get_pipeline_from_id(pipeline_id)
        
        competencies = req[c.FRAMEWORKS].get(c.COMPETENCY)
        occupations = req[c.FRAMEWORKS].get(c.OCCUPATION)
        industries = req[c.FRAMEWORKS].get(c.INDUSTRY)
        
        self.validate(pipeline_id, competencies)

        frameworks = self.compile_frameworks(competencies, occupations, industries)
        self.store_given_frameworks(pipeline, frameworks)

        resp_data = self.create_response_data(pipeline_id)
        response = ResponseHandler.create_response(resp_data, 200)
        return response
Beispiel #11
0
    def post(self):
        req = request.get_json()
        pipeline_id = RequestHandler.get_pipeline_id(req, True)
        pipeline = Pipeline.get_pipeline_from_id(pipeline_id)

        job_schema_plus_file = generate_job_schema_plus(pipeline_id)

        schema, data = self.convert_jspf_to_human_readable(
            pipeline, job_schema_plus_file)

        resp_data = self.create_response_data(pipeline_id,
                                              job_schema_plus_file, schema,
                                              data)

        self.save_output(job_schema_plus_file, schema, data, pipeline_id)

        response = ResponseHandler.create_response(resp_data, 200)
        return response
Beispiel #12
0
    def post(self):
        self.validate_file_in_request(request)

        file = self.get_file_from_request(request)
        file_name, file_format = self.extract_file_properties(file)

        file_text = extract_text(file, file_name, file_format)

        converted_length = get_length_of_job_description(file_text)

        req_identity = get_req_identity(request)

        new_pipeline = Pipeline.create_new_pipeline(req_identity, file_name,
                                                    file_format, file_text)
        pipeline_id = new_pipeline.pipeline_id

        self.save_file(file, file_name, file_format, pipeline_id)

        resp_data = self.create_response_data(pipeline_id, new_pipeline,
                                              converted_length)
        response = ResponseHandler.create_response(resp_data, 200)
        return response
Beispiel #13
0
    def _():

        new_pipeline = Pipeline(user_token=uuid.uuid4(),
                                file_name='test',
                                file_format='test',
                                file_text='test')

        DB.session.add(new_pipeline)
        DB.session.commit()

        my_pipeline_id = new_pipeline.pipeline_id

        first_recommendation = FrameworkRecommendation(
            user_token=uuid.uuid4(),
            value='1',
            valid_until=datetime.datetime.now(),
            pipeline_id=my_pipeline_id,
            user_type='test',
            object_type='test',
            statistic_type='test',
            metric_class='test',
            total_number=1234,
            recommended_content='test')

        second_recommendation = FrameworkRecommendation(
            user_token=uuid.uuid4(),
            value='2',
            valid_until=datetime.datetime.now(),
            pipeline_id=my_pipeline_id,
            user_type='test',
            object_type='test',
            statistic_type='test',
            metric_class='test',
            total_number=1234,
            recommended_content='test')

        DB.session.add(first_recommendation)
        DB.session.add(second_recommendation)
        DB.session.commit()

        # TODO mock calls to nameko
        @it('returns boths', skip=True)
        def _():
            request_body = {'pipelineID': str(my_pipeline_id)}

            # expected_body = [
            #     {
            #         'value': '1',
            #         'validUntil': '2019-05-17 17:19:02.206799',
            #         'metrics': {
            #             'userType': 'test',
            #             'pipelineID': 'ca22f6a5-7cfd-4ca8-9170-aabc528e80d1',
            #             'objectType': 'test',
            #             'statisticsType': 'test',
            #             'extraInfo': {
            #                 'totalNumber': '1234',
            #                 'recommendedContent': 'test'
            #             },
            #         'metricClass': 'test'}
            #     },{
            #         'value': '2',
            #         'validUntil': '2019-05-17 17:19:02.206884',
            #         'metrics': {
            #             'userType': 'test',
            #             'pipelineID': 'ca22f6a5-7cfd-4ca8-9170-aabc528e80d1',
            #             'objectType': 'test',
            #             'statisticsType': 'test',
            #             'extraInfo': {
            #                 'totalNumber': '1234',
            #                 'recommendedContent': 'test'
            #             },
            #         'metricClass': 'test'}
            #     }
            # ]

            resp = application.post_json('/framework-recommendations',
                                         request_body)

            expect(resp.status_int).to(equal(200))

            response_count = len(resp.json['frameworkRecommendations'])
            expect(response_count).to(equal(2))
Beispiel #14
0
    def _():

        new_pipeline = Pipeline(
            user_token=uuid.uuid4(),
            file_name='test',
            file_format='test',
            file_text='test'
        )

        DB.session.add(new_pipeline)
        DB.session.commit()

        my_pipeline_id = new_pipeline.pipeline_id

        @describe('and framework recommendations have been generated')
        def _():

            first_recommendation = FrameworkRecommendation(
                user_token=uuid.uuid4(),
                value='1',
                valid_until=datetime.datetime.now(),
                pipeline_id=my_pipeline_id,
                user_type='test',
                object_type='test',
                statistic_type='test',
                metric_class='test',
                total_number=1234,
                recommended_content='test'
            )

            second_recommendation = FrameworkRecommendation(
                user_token=uuid.uuid4(),
                value='2',
                valid_until=datetime.datetime.now(),
                pipeline_id=my_pipeline_id,
                user_type='test',
                object_type='test',
                statistic_type='test',
                metric_class='test',
                total_number=1234,
                recommended_content='test'
            )

            DB.session.add_all([
                first_recommendation,
                second_recommendation
            ])
            DB.session.commit()



            # prepopulating db
            competency_framework_type = FrameworkType(
                framework_type="competency"
            )

            occupation_framework_type = FrameworkType(
                framework_type="occupation"
            )

            industry_framework_type = FrameworkType(
                framework_type="industry"
            )

            DB.session.add_all([
                competency_framework_type,
                occupation_framework_type,
                industry_framework_type
            ])

            competency_framework = Framework(
                framework_type=competency_framework_type,
                framework_name="name7",
                framework_description="description",
                framework_uri="uri.com",
            )

            occupation_framework = Framework(
                framework_type=occupation_framework_type,
                framework_name="name8",
                framework_description="description",
                framework_uri="uri.com",
            )

            industry_framework = Framework(
                framework_type=industry_framework_type,
                framework_name="name9",
                framework_description="description",
                framework_uri="uri.com",
            )

            DB.session.add_all([
                competency_framework,
                occupation_framework,
                industry_framework
            ])
            DB.session.commit()

            @it('it accepts good data')
            def _():                
                request_body = {
                    "pipelineID": str(my_pipeline_id),
                    "frameworks": {
                        "competency": [
                            {
                                "frameworkID": str(competency_framework.framework_id)
                            }
                        ],
                        "occupation": [
                            {
                                "frameworkID": str(occupation_framework.framework_id)
                            }
                        ],
                        "industry": [
                            {
                                "frameworkID": str(industry_framework.framework_id)
                            }
                        ]
                    }
                }
                
                # print(expected_body)
                resp = application.post_json('/framework-selections', request_body)

                expect(resp.status_int).to(equal(200))                
                # expect(resp.json).to(equal(request_body))
            
            @it('when given only competencies its ok')
            def _():
                DB.session.add_all([
                    new_pipeline,
                    first_recommendation,
                    second_recommendation,
                    competency_framework_type,
                    occupation_framework_type,
                    industry_framework_type,
                    competency_framework,
                    occupation_framework,
                    industry_framework
                ])           
                request_body = {
                    "pipelineID": str(my_pipeline_id),
                    "frameworks": {
                        "competency": [
                            {
                                "frameworkID": str(competency_framework.framework_id)
                            },
                            {
                                "frameworkID": str(competency_framework.framework_id)
                            }
                        ]
                    }
                }
                
                # print(expected_body)
                resp = application.post_json('/framework-selections', request_body)

                expect(resp.status_int).to(equal(200))                
                # expect(resp.json).to(equal(request_body))
            
            @it('when given no frameworks it errors')
            def _():
                nonlocal new_pipeline
                DB.session.add_all([
                    new_pipeline,
                    first_recommendation,
                    second_recommendation,
                    competency_framework_type,
                    occupation_framework_type,
                    industry_framework_type,
                    competency_framework,
                    occupation_framework,
                    industry_framework
                ])

                request_body = {
                    "pipelineID": str(my_pipeline_id),
                    "frameworks": {}
                }
                
                resp = application.post_json('/framework-selections', request_body, expect_errors=True)

                expect(resp.status_int).to(equal(422))
                        
            @it('when given no pipeline it errors')
            def _():
                nonlocal new_pipeline
                DB.session.add_all([
                    new_pipeline,
                    first_recommendation,
                    second_recommendation,
                    competency_framework_type,
                    occupation_framework_type,
                    industry_framework_type,
                    competency_framework,
                    occupation_framework,
                    industry_framework
                ])

                request_body = {
                    "frameworks": {
                        "competency": [
                            {
                                "frameworkID": str(competency_framework.framework_id)
                            }
                        ],
                        "occupation": [
                            {
                                "frameworkID": str(occupation_framework.framework_id)
                            }
                        ],
                        "industry": [
                            {
                                "frameworkID": str(industry_framework.framework_id)
                            }
                        ]
                    }
                }
                
                resp = application.post_json('/framework-selections', request_body, expect_errors=True)

                expect(resp.status_int).to(equal(422))
def _():

    DB = get_db()
    DB.session.expire_on_commit = False

    my_pipeline = Pipeline(user_token=uuid.uuid4(),
                           file_name="file_name",
                           file_format="file_format",
                           file_text="file_text")

    DB.session.add(my_pipeline)
    DB.session.commit()

    my_pipeline_id = my_pipeline.pipeline_id

    @it('Pipeline.user_is_authorized_to_access_pipeline', skip=True)
    def _():
        pass

    @describe('when dealing with /match-table')
    def _():
        @it('can add match_table_data as json')
        def _():
            my_pipeline.match_table_data = match_table_dict
            DB.session.commit()

            expect(isinstance(my_pipeline.match_table_data, dict)).to(be_true)

        @it('can add match_table_selection as json')
        def _():
            my_pipeline.match_table_selections = match_table_selections
            DB.session.commit()

            expect(isinstance(my_pipeline.match_table_selections,
                              dict)).to(be_true)

    @it('pipeline can recieve frameworks')
    def _():
        competency_framework_type = FrameworkType(framework_type="competency")

        occupation_framework_type = FrameworkType(framework_type="occupation")

        industry_framework_type = FrameworkType(framework_type="industry")

        DB.session.add_all([
            competency_framework_type, occupation_framework_type,
            industry_framework_type
        ])
        DB.session.commit()

        competency_framework = Framework(
            framework_type=competency_framework_type,
            framework_name="name4",
            framework_description="description",
            framework_uri="uri.com",
        )

        occupation_framework = Framework(
            framework_type=occupation_framework_type,
            framework_name="name5",
            framework_description="description",
            framework_uri="uri.com",
        )

        industry_framework = Framework(
            framework_type=industry_framework_type,
            framework_name="name6",
            framework_description="description",
            framework_uri="uri.com",
        )

        DB.session.add_all(
            [competency_framework, occupation_framework, industry_framework])

        DB.session.commit()

        nonlocal my_pipeline
        nonlocal my_pipeline_id
        DB.session.add(my_pipeline)
        my_pipeline = DB.session.query(Pipeline).filter_by(
            pipeline_id=my_pipeline_id).one()

        my_pipeline.frameworks.append(competency_framework)
        my_pipeline.frameworks.append(occupation_framework)
        my_pipeline.frameworks.append(industry_framework)

        framework_count = len(my_pipeline.frameworks)
        expect(framework_count).to(equal(3))

        expect(my_pipeline.frameworks[0].framework_id).to(
            equal(competency_framework.framework_id))
        expect(my_pipeline.frameworks[1].framework_id).to(
            equal(occupation_framework.framework_id))
        expect(my_pipeline.frameworks[2].framework_id).to(
            equal(industry_framework.framework_id))
Beispiel #16
0
    def _():

        new_pipeline = Pipeline(
            user_token=uuid.uuid4(),
            file_name='test',
            file_format='test',
            file_text='test'
        )

        DB.session.add(new_pipeline)
        DB.session.commit()

        my_pipeline_id = new_pipeline.pipeline_id


        @it('it accepts good data')
        def _():
            # jobOverview
            #     title
            #     Description
            #     industry
            #     industryCode
            #     occupationCategory
            #     jobLocation
            #     jobLocationType
            #     employmentUnit
            #     positionID | postingID
            # employmentRelationship
            #     jobAgreement
            #     jobTerm
            #     jobSchedule
            #     workHours
            # competencyRelatedInformation
            #     requiredAssessment
            # hiringRequirements
            #     applicantLocationRequirement
            #     citizenshipRequirement
            #     physicalRequirement
            #     sensoryRequirement
            #     securityClearanceRequirement
            #     specialCommitment
            #     incentiveCompensation
            #     jobBenefits
            #     datePosted
            #     validThrough
            #     totalJobOpenings
            # education
            #     requiredCredential
            #     preferredCredential
            #     equivalentCredential
            #     minimumCredential
            #     requiredEducation
            #     preferredEducation
            #     equivalentEducation
            #     minimumEducation
            #     requiredExperience
            #     preferredExperience
            #     equivalentExperience
            #     minimumExperience
            # compensationInformation
            #     currency
            #     baseSalary
            request_body = {
                "pipelineID": str(my_pipeline_id),
                "context":
                    "title": "ACME cyber programmer"
                    "description": "aasdfasdf asdf asdf asdf  asdf asdf  asdfasdf asdf asdf asdf asfd."
                    "industry": "qwer"
                    "industryCode": "qwer"
                    "occupationCategory": "qwer"
                    "jobLocation": "qwer"
                    "jobLocationType": "qwer"
                    "employmentUnit": "qwer"
                    "positionID": "internal-id-string"
                    "jobAgreement": "qwer"
                    "jobTerm": "qwer"
                    "jobSchedule": "qwer"
                    "workHours": "qwer"
                    "requiredAssessment": "qwer"
                    "applicantLocationRequirement": "qwer"
                    "citizenshipRequirement": "qwer"
                    "physicalRequirement": "qwer"
                    "sensoryRequirement": "qwer"
                    "securityClearanceRequirement": "qwer"
                    "specialCommitment": "qwer"
                    "incentiveCompensation": "qwer"
                    "jobBenefits": "qwer"
                    "datePosted": "qwer"
                    "validThrough": "qwer"
                    "totalJobOpenings": "qwer"
                    "requiredCredential": "qwer"
                    "preferredCredential": "qwer"
                    "equivalentCredential": "qwer"
                    "minimumCredential": "qwer"
                    "requiredEducation": "qwer"
                    "preferredEducation": "qwer"
                    "equivalentEducation": "qwer"
                    "minimumEducation": "qwer"
                    "requiredExperience": "qwer"
                    "preferredExperience": "qwer"
                    "equivalentExperience": "qwer"
                    "minimumExperience": "qwer"
                    "currency": "qwer"
                    "baseSalary": "qwer"
            }

            request_body = {
                "pipelineID": str(my_pipeline_id),
                "primaryEconomicActivity": "Making and selling software products",
                "jobLocation": {
                    "name": "ACME Fairfax",
                    "description": "A place where software is built",
                    "faxNumber": "+17039999999",
                    "telephone": "+17039999999",
                    "address": {
                        "name": "ACME Fairfax",
                        "streetAddress": "101 Acme Way",
                        "locality": "Fairfax",
                        "region": "Virgina",
                        "country": "United States of America",
                        "postalCode": 22032
                    },
                    "geo": {
                        "latitude": 123.4554534534,
                        "longitude": 223.4554534534
                    }
                },
                "occupationCategory": {
                    "name": "SOC",
                    "description": "Standardized Occupation Code, for use in the US",
                    "termCode": "15-1131.00",
                    "definedTermSet": "Standard Occupational Classification system"
                },
                "industryCategory": {
                    "name": "SOC",
                    "description": "Standardized Occupation Code, for use in the US",
                    "termCode": "15-1131.00",
                    "definedTermSet": "Standard Occupational Classification system"
                }
                # "responsibilties": [
                #     "walking the dog",
                #     "writing code",
                #     "attending meetings"
                # ]
            }

            # expected_body = request_body
            # print(expected_body)
            resp = application.post_json('/upload-job-description-context', request_body)

            expect(resp.status_int).to(equal(200))
            
            expect(resp.json).to(have_keys(request_body))