Beispiel #1
0
def json_vacancies():
    list_vacancies = get_visible_vacancies_list()
    list_categories = [c.bl.as_dict() for c in Category.query.all()]
    list_cities = [v.bl.as_dict() for v in City.query.all()]
    return jsonify(
        vacancies=list_vacancies,
        categories=list_categories,
        cities=list_cities,
    )
Beispiel #2
0
def json_vacancies():
    list_vacancies = get_visible_vacancies_list()
    list_categories = [c.bl.as_dict() for c in Category.query.all()]
    list_cities = [v.bl.as_dict() for v in City.query.all()]
    return jsonify(
        vacancies=list_vacancies,
        categories=list_categories,
        cities=list_cities,
    )
Beispiel #3
0
    def test_vacancies_json(self):
        url = url_for('feed.json_vacancies')
        resp = self.client.get(url)
        cities = resp.json['cities']
        categories = resp.json['categories']
        vacancies = resp.json['vacancies']

        self.assertEqual(cities, [c.bl.as_dict() for c in City.query.all()])
        self.assertEqual(categories,
                         [c.bl.as_dict() for c in Category.query.all()])

        # after json datetime repr as str
        list_vacanies = get_visible_vacancies_list()
        list_vacanies = loads(
            jsonify(data=list_vacanies).data.decode())['data']
        self.assertEqual(
            vacancies,
            list_vacanies,
        )
Beispiel #4
0
    def test_get_visible(self):
        visible_list = get_visible_vacancies_list()
        vacancy_list = Vacancy.query.all()

        for vacancy in vacancy_list:
            if vacancy.condition_is_deleted:
                self.assertTrue(
                    vacancy.title not in (v["title"] for v in visible_list),
                    msg="Vacancy returned by get_visible but it is deleted",
                )
            elif vacancy.condition_is_hidden:
                self.assertTrue(
                    vacancy.title not in (v["title"] for v in visible_list),
                    msg="Vacancy returned by get_visible but it is hide",
                )
            else:
                self.assertTrue(
                    vacancy.title in (v["title"] for v in visible_list),
                    msg="There is a visible vacancy which is not returned" "with get_visible",
                )
Beispiel #5
0
    def test_get_visible(self):
        visible_list = get_visible_vacancies_list()
        vacancy_list = Vacancy.query.all()

        for vacancy in vacancy_list:
            if vacancy.condition_is_deleted:
                self.assertTrue(
                    vacancy.title not in (v['title'] for v in visible_list),
                    msg='Vacancy returned by get_visible but it is deleted'
                )
            elif vacancy.condition_is_hidden:
                self.assertTrue(
                    vacancy.title not in (v['title'] for v in visible_list),
                    msg='Vacancy returned by get_visible but it is hide'
                )
            else:
                self.assertTrue(
                    vacancy.title in (v['title'] for v in visible_list),
                    msg='There is a visible vacancy which is not returned'
                        'with get_visible'
                )
Beispiel #6
0
    def test_vacancies_json(self):
        url = url_for('feed.json_vacancies')
        resp = self.client.get(url)
        cities = resp.json['cities']
        categories = resp.json['categories']
        vacancies = resp.json['vacancies']

        self.assertEqual(cities, [c.bl.as_dict() for c in City.query.all()])
        self.assertEqual(
            categories,
            [c.bl.as_dict() for c in Category.query.all()]
        )

        # after json datetime repr as str
        list_vacanies = get_visible_vacancies_list()
        list_vacanies = loads(
            jsonify(data=list_vacanies).data.decode()
        )['data']
        self.assertEqual(
            vacancies,
            list_vacanies,
        )