Exemplo n.º 1
0
    def setUp(self):
        super(PostajobTestBase, self).setUp()
        self.client = TestClient(HTTP_HOST="test.jobs")
        self.posting_access = AppAccessFactory(name="Posting")
        self.marketplace_access = AppAccessFactory(name="MarketPlace")
        self.user = UserFactory(password="******")
        self.company = CompanyFactory(app_access=[self.posting_access, self.marketplace_access])
        self.posting_activities = [
            ActivityFactory(name=activity, app_access=self.posting_access)
            for activity in ["create job", "read job", "update job"]
        ]
        self.marketplace_activities = [
            ActivityFactory(name=activity, app_access=self.marketplace_access)
            for activity in [
                "create product",
                "read product",
                "update product",
                "create grouping",
                "read grouping",
                "update grouping",
                "delete grouping",
                "create purchased product",
                "read purchased product",
                "create purchased job",
                "read purchased job",
                "update purchased job",
                "read request",
                "update request",
                "create offline purchase",
                "read offline purchase",
                "update offline purchase",
                "delete offline purchase",
            ]
        ]
        self.admin_role = RoleFactory(
            company=self.company, name="Admin", activities=self.posting_activities + self.marketplace_activities
        )
        self.user.roles.add(self.admin_role)

        self.site = SeoSiteFactory(canonical_company=self.company, domain="test.jobs")
        self.bu = BusinessUnitFactory()
        self.site.business_units.add(self.bu)
        self.company.job_source_ids.add(self.bu)

        SitePackageFactory(owner=self.company)
        self.package = Package.objects.get()
        self.sitepackage = SitePackage.objects.get()
        self.sitepackage.sites.add(self.site)
        self.product = ProductFactory(package=self.package, owner=self.company)

        # create a login block so that the redirect works
        block = LoginBlockFactory()
        row = RowFactory()
        BlockOrderFactory(block=block, row=row, order=1)
        page = PageFactory(sites=[self.site])
        RowOrderFactory(row=row, page=page, order=1)

        self.login_user()