def test_existing_job_gets_updated(self): category = CategoryFactory.create(name='test category') PositionFactory.create(shortcode='foo', category=category) data = {'jobs': [{'state': 'published', 'shortcode': 'foo'}]} position_data = { 'employment_type': 'type', 'shortcode': 'foo', 'title': 'title', 'shortlink': 'http://foo.bar', 'location': { 'city': 'Paradise', 'telecommuting': True }, 'application_url': 'http://example.com', 'full_description': '<h3>title</h3> test' } with patch(self.spec) as requests_mock: requests_mock.get().json.side_effect = [data, position_data] self.command.handle() self.assertEqual(requests_mock.get.call_count, 3) position = Position.objects.get(shortcode='foo') self.assertEqual(position.job_type, 'type') self.assertEqual(position.title, 'title') self.assertEqual(position.detail_url, 'http://foo.bar') self.assertEqual(position.apply_url, 'http://example.com') self.assertEqual(position.location, 'Paradise, Remote') self.assertEqual(position.description, 'title test') self.assertEqual(Position.objects.all().count(), 1) self.assertEqual(Category.objects.all().count(), 1) self.assertEqual(Category.objects.all()[0].name, 'Mozilla Foundation')
def test_existing_job_gets_updated(self): category = CategoryFactory.create(name='test category') PositionFactory.create(shortcode='foo', category=category) data = {'jobs': [{'state': 'published', 'shortcode': 'foo'}]} position_data = {'employment_type': 'type', 'shortcode': 'foo', 'title': 'title', 'shortlink': 'http://foo.bar', 'location': {'city': 'Paradise', 'telecommuting': True}, 'application_url': 'http://example.com', 'full_description': '<h3>title</h3> test'} with patch(self.spec) as requests_mock: requests_mock.get().json.side_effect = [data, position_data] self.command.handle() eq_(requests_mock.get.call_count, 3) position = Position.objects.get(shortcode='foo') eq_(position.job_type, 'type') eq_(position.title, 'title') eq_(position.detail_url, 'http://foo.bar') eq_(position.apply_url, 'http://example.com') eq_(position.location, 'Paradise, Remote') eq_(position.description, 'title test') eq_(Position.objects.all().count(), 1) eq_(Category.objects.all().count(), 1) eq_(Category.objects.all()[0].name, 'Mozilla Foundation')
def test_base(self): jobvite_1 = JobviteCategoryFactory.create(name='ccc') workable_1 = WorkableCategoryFactory.create(name='bbb') jobvite_2 = JobviteCategoryFactory.create(name='aaa') categories = utils.get_all_categories() self.assertEqual(categories, [jobvite_2.name, workable_1.name, jobvite_1.name])