def test_position_get(self): """Test getting position details from the id""" position = interface.position_get(self.db, 1) self.assertEqual("CircleCI", position[5]) self.assertEqual("Staff Site Reliability Engineer ", position[3]) # get a position that doesn't exist, result should be None position = interface.position_get(self.db, 9999999) self.assertIsNone(position)
def expand(db, jobid): """Passing position data to the descexpander.html page by calling the position_get function from interface.py sending that info to the descexpander.html where it is separated and displayed accordingly. Returns the template along with the data of the given job id. Page with the full description of the position at the URL /positions/jobid where jobid is the position id.""" data = { 'description': interface.position_get(db, jobid) } return template('descexpander.html', data)
def display_job(db,id): """ :param id: Takes id as parameter from the 'Read more' hyperlink. This id is the unique id of job position. :return: Returns template page position.html when request is made to the server for route '/position/DD' where DD is the particular id """ position = interface.position_get(db,id) # Calling position_get method which returns all the details of the particular #job position active_user = users.session_user(db) message = dict() # Creating dictionary entry message["user"] = active_user message["title"] = "Job Position" return template("position", message=message , position = position)
def position(db, id): joblist = list(interface.position_get(db, id)) name = users.session_user(db) info = { 'title': 'The Chalkboard', 'message': 'Welcome to Jobs!', 'jobtitle': joblist[3], 'timestamp': joblist[1], 'company': joblist[5], 'location': joblist[4], 'description': joblist[6], 'owner': joblist[2], 'name': name } return template('positions', info)
def test_position_page_content(self): """Test that the page at /positions/DD has the description of the position number DD""" # test relies on interface.position_get working id = 10 position = interface.position_get(self.db, id) self.assertEqual(7, len(position)) self.assertEqual(id, position[0]) # now get the page response = self.app.get('/positions/%d' % id) # and look for the details for data in position[1:5]: escaped = html.escape(data) self.assertIn(escaped, response) # but the description should not be escaped self.assertIn(position[6], response)
def position_detail(db, id): """ Retrieves a position with the given id :param db: Database comnnection :param id: ID of the position :return: The page with content """ position = position_get(db, id) obj = { "id": position[0], "color": COLOR_CHOICES[random.randint(0, len(COLOR_CHOICES) - 1)], "timestamp": position[1], "owner": position[2], "title": position[3], "location": position[4], "company": position[5], "description": position[6], 'next': "/position/" + str(int(id) + 1) + "/", 'previous': "/position/" + str(int(id) - 1) + "/" } return template('position_detail', obj)
def read_more(db, DD): """displays detailed position job description when user clicks 'Read More' link """ position_data = interface.position_get(db, DD) return template('positionDetails', rows=position_data)
def positions(db, id): data1 = {'description': interface.position_get(db, id)} return template('positions.html', data1)
def position(db, id): data = position_get(db, id) info = {'title': 'Position Info', 'data': data} return template('position_info', info)