def main():
    parser, options = parse_command_line()

    if options.allocate:
        if not options.match:
            raise Exception('Match number is required to create allocation')

        match_no = options.match
        cand = Candidate()
        candidates = cand.get_all()
        if candidates:
            allocation_ser = Allocation()
            allocations = allocation_ser.generate_allocation(candidates)
            match_ser = Match()
            match = match_ser.get(match_no)
            if not match:
                raise Exception('Match number not valid')

            aloc_values = allocation_ser.create_allocation(match, allocations)
            html_to_send = generate_html_from_dics(aloc_values)
            candidate_emails = [c['email'] for c in candidates]
            send_mail(
                candidate_emails,
                'SS Dabba Party Allocation - Trip: ' + match_no,
                'A refers to the team which will bat first and B is who is batting 2nd',
                html_to_send)

    elif options.results:
        if not options.match:
            raise Exception('Match number is required to create results')

        match_no = options.match
        result_service = MatchResults()
        results = result_service.get(match_no)

        aloc_service = Allocation()
        allocations = aloc_service.get_allocation(match_no)

        final_results = generate_candidate_result(allocations, results)

        match_service = Match()
        match_obj = match_service.get(match_no)

        cand_result_service = CandidateResult()
        result_values = cand_result_service.add_results(
            match_obj, final_results)
        html_to_send = generate_html_from_dics(result_values)
        candidate_emails = [res['name'] for res in final_results['results']]
        send_mail(candidate_emails,
                  'SS Dabba Party Result - Trip: ' + match_no,
                  'Result as following', html_to_send)
Esempio n. 2
0
def create_candidates(candidates: Dict) -> List[Candidate]:
    """Converts candidates records from dict to objects"""
    result = []
    for i in range(len(candidates['fios'])):
        result.append(
            Candidate(
                position=candidates['positions'][i],
                fio=candidates['fios'][i],
                salary=candidates['salary_requests'][i],
                comment=candidates['comments'][i],
                status_text=candidates['statuses'][i],
            ))
    return result
Esempio n. 3
0
    def add_candidate_to_vacancy(self, candidate: Candidate) -> None:
        """POST /account/{account_id}/applicants/{applicant_id}/vacancy

        В теле запроса необходимо передать JSON вида:
            {
                "vacancy": 988,         << required
                "status": 1230,         << required
                "comment": "Привет",
                "files": [
                    {
                        "id": 1382810   << required
                    }
                ],
                "rejection_reason": null
            }
        """
        for vacancy in self.vacancies:
            if candidate.is_suitable_for(vacancy):
                payload = {
                    "vacancy":
                    vacancy.id,
                    "status":
                    candidate.status_id,
                    "comment":
                    candidate.comment,
                    "files":
                    None,  # todo work on it
                    "rejection_reason":
                    candidate.comment if candidate.status_id == 50 else None
                }
                url = self._add_candidate_to_vacancy_url
                response = self.post(url=url,
                                     headers=self._auth_header,
                                     payload=payload)
                # todo handle response data
                return
Esempio n. 4
0
def test_candidate_status_code_post():
        assert Candidate().post('Olga', 'Junior Automation QA').status_code == 201
Esempio n. 5
0
def test_candidate_status_code_get(cid):
        assert Candidate().get(cid).status_code == 200
Esempio n. 6
0
def test_candidate_status_code_delete(cid):
        assert Candidate().delete(cid).status_code == 200
Esempio n. 7
0
def test_candidate_status_code_post():
    assert Candidate().post('Marina', 'VP Director Senior Automation QA Architect').status_code == 201
Esempio n. 8
0
def test_candidate_status_code_del(self):
    assert Candidate().delete(del_cand).status_code == 200
 def test_candidate_content_get(self, cid):
     assert Candidate().get(cid).json()
def test_candidate_status_code_del():
    assert Candidate().delete(maxid+12).status_code == 200
 def test_candidate_status_code_post(self, position):
     assert Candidate().post('Marian Shun', position).json()