コード例 #1
0
def test_parse_job_listings(monster_parser):
    mockJobListingsPage = mocked_requests_get(mockJobListingURL)

    jobListingsParser = BeautifulSoup(mockJobListingsPage.content, 'lxml')
    jobListings = jobListingsParser.find_all('section',
                                             attrs={'class': 'card-content'})
    monster_parser.parseJobListings(jobListings)

    assert len(monster_parser.jobListings) == 4
コード例 #2
0
def test_parse_job_listings(stack_overflow_parser):
    mockJobListingsPage = mocked_requests_get(mockJobListingURL)

    jobListingsParser = BeautifulSoup(mockJobListingsPage.content, 'lxml')
    jobListings = jobListingsParser.find_all('div',
                                             attrs={'class': '-job-summary'})
    stack_overflow_parser.parseJobListings(jobListings)

    assert len(stack_overflow_parser.jobListings) == 3
コード例 #3
0
def test_time_parser(monster_parser):
    mockJobListingPage = mocked_requests_get(
        urljoin(mockJobListingURL, 'jobs/search'))

    jobListingParser = BeautifulSoup(mockJobListingPage.content, 'lxml')

    postDateRaw = jobListingParser.find('time').text
    parsedDate = dateParserMonster(postDateRaw)

    datePattern = "%m/%d/%Y"
    assert parsedDate.strftime(datePattern) == (
        datetime.now() + relativedelta(days=-10)).strftime(datePattern)
コード例 #4
0
def test_time_parser(stack_overflow_parser):
    mockJobListingPage = mocked_requests_get(urljoin(mockJobListingURL,
                                                     'jobs'))

    jobListingParser = BeautifulSoup(mockJobListingPage.content, 'lxml')
    jobHeaderInfo = jobListingParser.find('div', attrs={'class': '-title'})

    postedDateRaw = jobHeaderInfo.find('span', attrs={
        'class': 'fc-black-500'
    }).text
    parsedTime = dateParserStackOverflow(postedDateRaw)

    datePattern = "%m/%d/%Y"
    assert parsedTime.strftime(datePattern) == (
        datetime.now() + relativedelta(days=-1)).strftime(datePattern)
コード例 #5
0
def test_create_job_listing(stack_overflow_parser):
    mockJobListingPage = mocked_requests_get(urljoin(mockJobListingURL,
                                                     'jobs'))

    jobListingParser = BeautifulSoup(mockJobListingPage.content, 'lxml')
    jobListing = stack_overflow_parser.createJobListing(jobListingParser)

    assert isinstance(jobListing, JobListing)
    assert jobListing.jobTitle == 'Software Developer'
    assert jobListing.jobURL == mockJobListingURL
    assert jobListing.companyName == 'ABC Company'
    assert jobListing.jobLocation == 'New York, NY'

    datePattern = "%m/%d/%Y"
    assert jobListing.postDate.strftime(datePattern) == (
        datetime.now() + relativedelta(days=-1)).strftime(datePattern)
コード例 #6
0
def test_create_job_listing(monster_parser):
    mockJobListingPage = mocked_requests_get(
        urljoin(mockJobListingURL, 'jobs/search'))

    jobListingParser = BeautifulSoup(mockJobListingPage.content, 'lxml')

    jobListing = monster_parser.createJobListing(jobListingParser)

    assert isinstance(jobListing, JobListing)
    assert jobListing.jobTitle == 'AWS Architect'
    assert jobListing.jobURL == mockJobListingURL
    assert jobListing.companyName == 'Tech Solutions Inc'
    assert jobListing.jobLocation == 'Parsippany, NJ'

    datePattern = "%m/%d/%Y"
    assert jobListing.postDate.strftime(datePattern) == (
        datetime.now() + relativedelta(days=-10)).strftime(datePattern)
コード例 #7
0
def test_get_job_listings(mock_get, monster_parser):
    mock_get.return_value = mocked_requests_get(mockJobListingURL)

    jobListings = monster_parser.getJobListings()

    assert len(jobListings) == 4
コード例 #8
0
def test_get_job_listings(mock_get, stack_overflow_parser):
    mock_get.return_value = mocked_requests_get(mockJobListingURL)

    jobListings = stack_overflow_parser.getJobListings()

    assert len(jobListings) == 3