def setUpTestData(cls): url = "https://elections.huffingtonpost.com/pollster/api/v2/polls?cursor=28987&sort=created_at.json" parse_pollster_data(url) url = "https://elections.huffingtonpost.com/pollster/api/v2/polls?cursor=28962&sort=created_at.json" parse_pollster_data(url) url = 'https://bbotllc.github.io/candidate-interviews/political_leanings.json' parse_ny_data(url)
def test_pollster_no_extra_questions_repeated_load(self): num_q_before_load = Question.objects.count() url = "https://elections.huffingtonpost.com/pollster/api/v2/polls?cursor=28962&sort=created_at.json" parse_pollster_data(url) url = 'https://bbotllc.github.io/candidate-interviews/political_leanings.json' parse_ny_data(url) num_q_after_load = Question.objects.count() self.assertEqual(num_q_before_load, num_q_after_load)
def test_pollster_no_extra_choices_change_votes_repeated_load(self): num_c_before_load = Choice.objects.count() choice = Choice.objects.get(pk=1) choice.votes = 5 choice = Choice.objects.get(pk=10) choice.votes = 0 url = "https://elections.huffingtonpost.com/pollster/api/v2/polls?cursor=28962&sort=created_at.json" parse_pollster_data(url) url = 'https://bbotllc.github.io/candidate-interviews/political_leanings.json' parse_ny_data(url) num_c_after_load = Choice.objects.count() self.assertEqual(num_c_before_load, num_c_after_load)
def test_returned_next_cursor_correct(self): expected_next_cursor = "28962" url = "https://elections.huffingtonpost.com/pollster/api/v2/polls?cursor=28987&sort=created_at.json" next_cursor = parse_pollster_data(url) self.assertEqual(expected_next_cursor, next_cursor)
def setUpTestData(cls): rel_url = "parse_files/pollster_sample.json" abs_url = os.path.abspath(rel_url) local_pollster_url = "file://" + abs_url parse_pollster_data(local_pollster_url)
def setUpTestData(cls): url = "https://elections.huffingtonpost.com/pollster/api/v2/polls?cursor=28987&sort=created_at.json" parse_pollster_data(url) url = "https://elections.huffingtonpost.com/pollster/api/v2/polls?cursor=28962&sort=created_at.json" parse_pollster_data(url)