def get_problem_info(problem):
    """Helper method that gets problem info"""
    if problem not in repo_data.get_problems():
        raise NameError('Problem does not exist')

    contributors_solved = repo_data.who_solved(problem)

    return [
        problem,
        repo_data.get_problem_popularity(problem),
        len(contributors_solved)
    ]
Example #2
0
 def test_database(self):
     with data_site.app.app_context():
         database = sqlite3.connect(data_site.app.config['DATABASE'])
         cur = database.execute(
             'SELECT username FROM Contributors').fetchall()
         self.assertListEqual(rd.top_contributors(),
                              [name[0] for name in cur])
         cur = database.execute(
             'SELECT problem_number FROM Problems').fetchall()
         self.assertListEqual(
             [int(problem) for problem in rd.get_problems()],
             [problem[0] for problem in cur])
 def test_get_problems(self):
     self.assertListEqual(rd.get_problems()[0:5],
                          ["001", "002", "003", "004", "005"])
     self.assertListEqual(rd.get_problems()[41:46],
                          ["055", "067", "079", "080", "085"])
def create_problems():
    """method to add all current problems to the database"""
    # loops through problems creating Problems
    for problem in repo_data.get_problems():
        # creates a new problem and adds it to the list
        add_problems(problem)