示例#1
0
    def test_on_sites_by_buid(self):
        business_unit = BusinessUnitFactory(pk=77)

        results = DEv2JobFeed('seo/tests/data/dseo_feed_0.xml',
                              jsid=business_unit.id,
                              markdown=business_unit.enable_markdown)
        jobs = results.solr_jobs()
        for job in jobs:
            self.assertItemsEqual(job['on_sites'], [0])

        site_package = SitePackageFactory(owner=self.company)
        business_unit.site_packages.add(site_package)

        results = DEv2JobFeed('seo/tests/data/dseo_feed_0.xml',
                              jsid=business_unit.id,
                              markdown=business_unit.enable_markdown)
        jobs = results.solr_jobs()
        for job in jobs:
            self.assertItemsEqual(job['on_sites'], [site_package.pk])

        site_package2 = SitePackageFactory(owner=self.company)
        business_unit.site_packages.add(site_package2)

        results = DEv2JobFeed('seo/tests/data/dseo_feed_0.xml',
                              jsid=business_unit.id,
                              markdown=business_unit.enable_markdown)
        jobs = results.solr_jobs()
        for job in jobs:
            self.assertItemsEqual(job['on_sites'], [site_package.pk,
                                                    site_package2.pk])

        site_package2.delete()
        site_package.delete()
        business_unit.delete()
示例#2
0
 def setUp(self):
     super(JobsFStoJsonTest, self).setUp()
     self.document = path.join(
         path.dirname(__file__),
         'data/789274C9-D0AA-49D6-8257-A8E977576183.xml')
     self.bu = BusinessUnitFactory()
     import_jobs.add_company(self.bu)
示例#3
0
    def test_company_slug(self):
        bu = BusinessUnitFactory(title_slug='test-bu', id=7, title='Test')
        path = '/%s/%s/' % (bu.title_slug, settings.SLUG_TAGS['company_slug'])

        self.filters['company_slug'] = bu.title_slug

        jobs = []

        query_dict = QueryDict('')

        breadbox = Breadbox(path, self.filters, jobs, query_dict)
        self.assertEqual(breadbox.company_breadcrumb.display_title, bu.title)
示例#4
0
    def setUp(self):
        super(LoadETLTestCase, self).setUp()
        self.zipfile = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                    'data',
                                    '0812fe95-e7cb-4eb5-813c-55c9180f6bd7.zip')
        with open(self.zipfile) as zf:
            self.jobs = list(get_jobs_from_zipfile(zf, "0812fe95-e7cb-4eb5-813c-55c9180f6bd7"))

        self.businessunit = BusinessUnitFactory(id=0)
        self.buid = self.businessunit.id
        self.guid = '0812fe95-e7cb-4eb5-813c-55c9180f6bd7'
        self.name = "Test"
示例#5
0
    def setUp(self):
        super(DirectSEOTestCase, self).setUp()
        self.solr_docs = solr_settings.SOLR_FIXTURE
        self.conn.add(self.solr_docs)

        # uids and numjobs in feed file for test business unit 0
        self.feed_uids = [
            57621597, 57311147, 60351047, 59891656, 58867671, 57495178,
            59773973, 59326433, 57311143, 57311166
        ]
        self.feed_numjobs = 14

        self.businessunit = BusinessUnitFactory(id=0)
        self.buid_id = self.businessunit.id
        # Ensure DATA_DIR used by import_jobs.download_feed_file exists
        data_path = DATA_DIR
        if not os.path.exists(data_path):
            os.mkdir(data_path)
示例#6
0
    def setUp(self):
        super(JobFeedTestCase, self).setUp()
        self.businessunit = BusinessUnitFactory(id=0)
        self.buid_id = self.businessunit.id
        self.numjobs = 14
        self.testdir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                    'data')
        self.company = CompanyFactory()
        self.company.job_source_ids.add(self.businessunit)
        self.company.save()
        self.conn = Solr("http://127.0.0.1:8983/solr/seo")
        self.emptyfeed = os.path.join(self.testdir, "dseo_feed_0.no_jobs.xml")
        self.malformed_feed = os.path.join(self.testdir, 'dseo_malformed_feed_0.xml')
        self.invalid_feed = os.path.join(self.testdir, 'dseo_invalid_feed_0.xml')
        self.unused_field_feed = os.path.join(self.testdir, 'dseo_feed_1.xml')
        self.no_onet_feed = os.path.join(self.testdir, 'dseo_feed_no_onets.xml')

        # Ensures DATA_DIR used by import_jobs.download_feed_file exists
        data_path = DATA_DIR
        if not os.path.exists(data_path):
            os.mkdir(data_path)
示例#7
0
    def test_subsidiary_rename(self):
        company1 = CompanyFactory()
        bu1 = self.businessunit
        bu1.title = "Acme corp"
        bu2 = BusinessUnitFactory(title=bu1.title)
        bu2.save()
        self.businessunit.company_set.add(company1)

        # Test that a company was created for both business units
        add_company(bu1)
        companies = bu1.company_set.all()
        self.assertEqual(len(companies), 1)
        co = companies[0]
        self.assertEqual(co.name, bu1.title)

        # Add the 2nd business unit
        add_company(bu2)

        # Both units should be attached to that company
        self.assertEqual(bu1.company_set.all()[0], bu2.company_set.all()[0])
        self.assertEqual(bu1.company_set.all().count(), 1)
        self.assertIn(bu1, co.job_source_ids.all())
        self.assertIn(bu2, co.job_source_ids.all())
        self.assertEqual(co.name, bu1.title)
        self.assertEqual(co.name, bu2.title)

        bu2.title = "New company name"
        add_company(bu1)
        add_company(bu2)
        self.assertEqual(len(co.job_source_ids.all()), 1)
        self.assertNotEqual(bu1.company_set.all(), bu2.company_set.all())
        self.assertEqual(co.name, bu1.title)
        self.assertEqual(len(bu2.company_set.all()), 1)
        co2 = bu2.company_set.all()[0]
        self.assertEqual(co2.name, bu2.title)
        self.assertNotEqual(co2.name, bu1.title)
        self.assertNotEqual(co.name, bu2.title)
示例#8
0
    def setUp(self):
        super(ModelTests, self).setUp()
        self.user = User.objects.create(email='*****@*****.**')
        self.company = CompanyFactory()
        CompanyProfile.objects.create(company=self.company)
        self.site = SeoSiteFactory()  #domain='buckconsoltants.jobs')
        self.bu = BusinessUnitFactory()
        self.site.business_units.add(self.bu)
        self.site.save()
        self.company.job_source_ids.add(self.bu)
        self.company.save()

        # Use the newly created site for testing instead of secure.my.jobs.
        settings.SITE = self.site

        self.request_data = {
            'title': 'title',
            'company': self.company.id,
            'reqid': '1',
            'description': 'sadfljasdfljasdflasdfj',
            'link': 'www.google.com',
            'on_sites': '0',
            'apply_info': '',
        }

        self.request_location = {
            'city': 'Indianapolis',
            'state': 'Indiana',
            'state_short': 'IN',
            'country': 'United States',
            'country_short': 'USA',
            'zipcode': '46268',
        }

        self.site_package_data = {
            'name': 'Test Site Package',
        }
示例#9
0
 def setUp(self):
     super(ImportJobsTestCase, self).setUp()
     self.businessunit = BusinessUnitFactory(id=0)
     self.buid_id = self.businessunit.id
     self.filepath = os.path.join(DATA_DIR, '0', 'dseo_feed_%s.xml' % self.buid_id)
示例#10
0
 def setUp(self):
     super(UpdatesTests, self).setUp()
     self.user = UserFactory()
     self.key = settings.BUID_API_KEY
     self.existing_bu = BusinessUnitFactory()
示例#11
0
    def setUp(self):
        super(BlocksTestBase, self).setUp()
        self.site = SeoSite.objects.get()
        self.config = Configuration.objects.get(status=2)
        self.config.browse_facet_show = True
        self.config.save()

        # Can't do a get_or_create here because we don't
        # care about the date_crawled/date_updated fields,
        # but if the BusinessUnit doesn't exist they will need
        # to be supplied.
        try:
            self.buid = BusinessUnit.objects.get(pk=0)
        except BusinessUnit.DoesNotExist:
            self.buid = BusinessUnitFactory(id=0)
        self.site.business_units.add(0)

        self.commitment = SpecialCommitmentFactory()
        self.site.special_commitments.add(self.commitment)
        self.site.save()

        self.tag = SiteTag.objects.create(site_tag='Test tag')
        self.site.site_tags.add(self.tag)
        self.site.save()

        self.job = SOLR_FIXTURE[1]
        self.conn.add([self.job])

        self.user = UserFactory()

        url = reverse('all_jobs')
        self.search_results_request = RequestFactory().get(url)
        self.search_results_request.user = self.user

        self.q_kwargs = {'q': self.job['title']}
        url = build_url(reverse('all_jobs'), self.q_kwargs)
        self.search_results_with_q_request = RequestFactory().get(url)
        self.search_results_with_q_request.user = self.user

        self.facet = CustomFacetFactory(show_production=True,
                                        name='%s' % self.job['title'],
                                        name_slug='%s' %
                                        self.job['title_slug'],
                                        querystring='*',
                                        blurb='Test')
        self.bad_facet = CustomFacetFactory(show_production=True,
                                            name='Bad Facet',
                                            name_slug='bad-facet',
                                            querystring='asfljasdlfjsadfsdf',
                                            blurb='Test',
                                            always_show=True)
        SeoSiteFacetFactory(customfacet=self.facet, seosite=self.site)
        SeoSiteFacetFactory(customfacet=self.bad_facet, seosite=self.site)

        url = '%s/new-jobs/' % self.job['title_slug']
        self.search_results_with_custom_facet = RequestFactory().get(url)
        self.search_results_with_custom_facet.user = self.user

        self.job_detail_kwargs = {
            'job_id': self.job['guid'],
            'title_slug': self.job['title_slug'],
            'location_slug': slugify(self.job['location']),
        }
        url = reverse('job_detail_by_location_slug_title_slug_job_id',
                      kwargs=self.job_detail_kwargs)
        self.job_detail_request = RequestFactory().get(url)
        self.job_detail_request.user = self.user

        kwargs = {'job_id': self.job['guid']}
        url = reverse('job_detail_by_job_id', kwargs=kwargs)
        self.job_detail_redirect_request = RequestFactory().get(url)
        self.job_detail_redirect_request.user = self.user

        # Send a request through middleware so all the required
        # settings (from MultiHostMiddleware) actually get set.
        self.client.get('/')