예제 #1
0
class JobUpdateTest(BaseJobTest):

    def take_care_of_conflicting_entities(self):
        self.role_helper.destroy(self.app, db)
        self.user_helper.destroy(self.app, db)
        self.user_role_helper.destroy(self.app, db)
        self.search_site_helper.destroy(self.app, db)
        self.job_offer_helper.destroy(self.app, db)

    def setUp(self):
        self.app = app
        self.app.testing = True
        self.app_client = self.app.test_client()

        self.role_helper = RoleHelper()
        self.user_helper = UserHelper()
        self.user_role_helper = UserRoleHelper()
        self.search_site_helper = SearchSiteHelper()
        self.job_offer_helper = JobOffereHelper()

        self.take_care_of_conflicting_entities()

        self.role_helper.create(self.app, db)
        self.user_helper.create(self.app, db)
        self.search_site_helper.create(self.app, db)
        self.user_role_helper.create(self.app, db)
        self.job_offer_helper.create(self.app, db)

        self.user_toolchain = UserTestToolChain()
        self.user_toolchain.set_user_helper(self.user_helper)

    def tearDown(self):
        try:
            self.role_helper.destroy(self.app, db)
            self.user_helper.destroy(self.app, db)
            self.user_role_helper.destroy(self.app, db)
            self.search_site_helper.destroy(self.app, db)
            self.job_offer_helper.destroy(self.app, db)
        except Exception as e:
            self.app.logger.debug("Error {error}".format(error=e.message))

    def test_update_job_offer(self):
        sessionid = self.user_toolchain.\
            provide_login_credential(self.app_client)
        headers = [('session', sessionid)]
        payload = json.dumps({"name": "Updated record",
                   "description": "Doesn't matter"})
        url = "/job-offers/{site_id}/".format(site_id=1)
        response = self.app_client.put(url, data=payload,
                                        content_type=JSON_HEADER,
                                        headers=headers)
        code = response.status_code
        msg = "Should be ok({ok}), but got {code}\n{msg}"\
            .format(code=code, ok=OK, msg=response.data)
        self.assertEquals(OK, code, msg)
예제 #2
0
class BaseJobTest(unittest.TestCase):

    def take_care_of_conflicting_entities(self):
        self.role_helper.destroy(self.app, db)
        self.user_helper.destroy(self.app, db)
        self.user_role_helper.destroy(self.app, db)
        self.search_site_helper.destroy(self.app, db)
        self.job_offer_helper.destroy(self.app, db)

    def setUp(self):
        self.app = app
        self.app.testing = True
        self.app_client = self.app.test_client()

        self.role_helper = RoleHelper()
        self.user_helper = UserHelper()
        self.user_role_helper = UserRoleHelper()
        self.search_site_helper = SearchSiteHelper()
        self.job_offer_helper = JobOffereHelper()

        self.take_care_of_conflicting_entities()

        self.role_helper.create(self.app, db)
        self.user_helper.create(self.app, db)
        self.search_site_helper.create(self.app, db)
        self.user_role_helper.create(self.app, db)
        self.job_offer_helper.create(self.app, db)

        self.user_toolchain = UserTestToolChain()
        self.user_toolchain.set_user_helper(self.user_helper)

    def tearDown(self):
        try:
            self.role_helper.destroy(self.app, db)
            self.user_helper.destroy(self.app, db)
            self.user_role_helper.destroy(self.app, db)
            self.search_site_helper.destroy(self.app, db)
            self.job_offer_helper.destroy(self.app, db)
        except Exception as e:
            self.app.logger.debug("Error {error}".format(error=e.message))
예제 #3
0
    def setUp(self):
        self.app = app
        self.app.testing = True
        self.app_client = self.app.test_client()

        self.role_helper = RoleHelper()
        self.user_helper = UserHelper()
        self.user_role_helper = UserRoleHelper()
        self.search_site_helper = SearchSiteHelper()
        self.job_offer_helper = JobOffereHelper()

        self.take_care_of_conflicting_entities()

        self.role_helper.create(self.app, db)
        self.user_helper.create(self.app, db)
        self.search_site_helper.create(self.app, db)
        self.user_role_helper.create(self.app, db)
        self.job_offer_helper.create(self.app, db)

        self.user_toolchain = UserTestToolChain()
        self.user_toolchain.set_user_helper(self.user_helper)
예제 #4
0
class JobGetTest(BaseJobTest):

    def take_care_of_conflicting_entities(self):
        self.role_helper.destroy(self.app, db)
        self.user_helper.destroy(self.app, db)
        self.user_role_helper.destroy(self.app, db)
        self.search_site_helper.destroy(self.app, db)
        self.job_offer_helper.destroy(self.app, db)

    def setUp(self):
        self.app = app
        self.app.testing = True
        self.app_client = self.app.test_client()

        self.role_helper = RoleHelper()
        self.user_helper = UserHelper()
        self.user_role_helper = UserRoleHelper()
        self.search_site_helper = SearchSiteHelper()
        self.job_offer_helper = JobOffereHelper()

        self.take_care_of_conflicting_entities()

        self.role_helper.create(self.app, db)
        self.user_helper.create(self.app, db)
        self.search_site_helper.create(self.app, db)
        self.user_role_helper.create(self.app, db)
        self.job_offer_helper.create(self.app, db)

        self.user_toolchain = UserTestToolChain()
        self.user_toolchain.set_user_helper(self.user_helper)

    def tearDown(self):
        try:
            self.role_helper.destroy(self.app, db)
            self.user_helper.destroy(self.app, db)
            self.user_role_helper.destroy(self.app, db)
            self.search_site_helper.destroy(self.app, db)
            self.job_offer_helper.destroy(self.app, db)
        except Exception as e:
            self.app.logger.debug("Error {error}".format(error=e.message))

    def test_get_job_offers(self):
        sessionid = self.user_toolchain.\
            provide_login_credential(self.app_client)
        headers = [('session', sessionid)]
        url = "/job-offers/"
        response = self.app_client.get(url, content_type=JSON_HEADER,
                                        headers=headers)
        code = response.status_code
        msg = "Should be ok({ok}), but got {code}\n{msg}"\
            .format(code=code, ok=OK, msg=response.data)
        self.assertEquals(OK, code, msg)

    def test_get_individual_job_offer(self):
        sessionid = self.user_toolchain.\
            provide_login_credential(self.app_client)
        headers = [('session', sessionid)]
        url = "/job-offers/{site_id}/".format(site_id=1)
        response = self.app_client.get(url, content_type=JSON_HEADER,
                                        headers=headers)
        code = response.status_code
        msg = "Should be ok({ok}), but got {code}\n{msg}"\
            .format(code=code, ok=OK, msg=response.data)
        self.assertEquals(OK, code, msg)

    def test_get_inexistent_job_offer(self):
        sessionid = self.user_toolchain.\
            provide_login_credential(self.app_client)
        headers = [('session', sessionid)]
        url = "/job-offers/{site_id}/".format(site_id=0)
        response = self.app_client.get(url, content_type=JSON_HEADER,
                                        headers=headers)
        code = response.status_code
        msg = "Should be ok({not_found}), but got {code}\n{msg}"\
            .format(code=code, not_found=NOT_FOUND, msg=response.data)
        self.assertEquals(NOT_FOUND, code, msg)