Exemplo n.º 1
0
def fake_job_items():
    return [
        JobItem(company='Fake Inc.',
                title="Position at fake department doing fake work.",
                url="www.fakeurl.com",
                details=JobDetails(category='Cool job',
                                   department='Fake department',
                                   summary=bacon[0],
                                   duties=bacon[1],
                                   skills='Word, Excel, Common sense',
                                   location='Hamburg, Germany')),
        JobItem(
            company='Fake Doors Ltd.',
            title="Intern to make coffee and other things nobody likes to do",
            url="www.fake-doors.com",
            details=JobDetails(
                category='Fake doors',
                department='Marketing and Sales',
                summary=bacon[3],
                duties=bacon[4],
                skills='You must be passionate about fake doors.',
                location='C137, Earth')),
        JobItem(company='Dream Factory Inc',
                title="Title description that says nothing",
                url="www.wow-our-jobs-are-so-cool-check-it-out.com",
                details=JobDetails(category='Dream Factory Inc',
                                   location='Beijing, CHina'))
    ]
Exemplo n.º 2
0
def test_to_html_non_verbose():
    company = 'company'
    title = 'title'
    url = 'www.test.com'
    description = JobDetails('cat', '', '', '', '', 'loc')
    item = JobItem(company, title, url, description)

    expected_verbose = (
        "<table frame='box'>"
        "<tbody>"
        "<tr><td width=20%><b>Title</b></td><td>title</td></tr>"
        "<tr><td width=20%><b>Category</b></td><td>cat</td></tr>"
        "<tr><td width=20%><b>Location</b></td><td>loc</td></tr>"
        "<tr><td width=20%><b>Url</b></td><td>www.test.com</td></tr>"
        "</tbody>"
        "</table>")
    expected_non_verbose = (
        "<table frame='box'>"
        "<tbody>"
        "<tr><td width=20%><b>Title</b></td><td>title</td></tr>"
        "<tr><td width=20%><b>Url</b></td><td>www.test.com</td></tr>"
        "</tbody>"
        "</table>")

    assert item.to_html(details=True) == expected_verbose
    assert item.to_html(details=False) == expected_non_verbose
Exemplo n.º 3
0
    def scrape_job_details(cls, response):
        _details_description_div = ('h2', {'text': 'Description of the job'})

        soup = BeautifulSoup(response.text, 'html.parser')

        return JobDetails(category=cls._get_category(soup),
                          department=cls._get_department(soup),
                          summary=cls._get_summary(soup),
                          duties=cls._get_duties(soup),
                          skills=cls._get_skills(soup),
                          location=cls._get_location(soup))
Exemplo n.º 4
0
def test_job_item_properties():
    company = 'company'
    title = 'title'
    description = JobDetails()
    url = 'www.test.com'
    item = JobItem(company, title, url, description)

    assert item.company == company
    assert item.title == title
    assert item.url == url
    assert isinstance(item.details, JobDetails)
Exemplo n.º 5
0
    def apply_job_details(self, job_items):
        # type: (List[JobItem]) -> List[JobItem]
        for job_item in job_items:
            try:
                response = self._fetch_url_response(job_item.url)
            except ValueError:
                log.warning(
                    f'Could not retrieve job details for :{job_item.title}')
                job_item.details = JobDetails()
            else:
                job_item.details = self.scraper.scrape_job_details(response)

        return job_items
Exemplo n.º 6
0
def test_job_details_properties():
    category = 'cat'
    department = 'dep'
    overview = 'overview'
    duties = 'duties'
    skills = 'skills'
    location = 'loc'
    descr = JobDetails(category, department, overview, duties, skills,
                       location)

    assert descr.category == category
    assert descr.department == department
    assert descr.summary == overview
    assert descr.duties == duties
    assert descr.skills == skills
    assert descr.location == location
Exemplo n.º 7
0
def test_job_details_has_entries():
    details = JobDetails()
    assert details.has_entries() is False
    details.skills = 'must know how to read'
    assert details.has_entries() is True
Exemplo n.º 8
0
def test_iter_job_details():
    details = JobDetails(category='cat', skills='skillz', location='loc')
    assert [d.value for d in details] == ['cat', '', '', '', 'skillz', 'loc']
Exemplo n.º 9
0
def test_job_details_instantiation():
    assert isinstance(JobDetails(), JobDetails)