Exemplo n.º 1
0
 def test_command_update_1_comic(self):
     response = xkcd.get_url(xkcd.api_url % "")
     new_max_comic = json.loads(response.decode("utf-8"))["num"] - 1
     xkcd.cur_max_comic = new_max_comic
     output = xkcd.command_update()
     expected_output = "1 new comic!\n"
     self.assertEqual(output, expected_output)
Exemplo n.º 2
0
 def test_command_update_no_new_comics(self):
     response = xkcd.get_url(xkcd.api_url % "")
     max_comic = json.loads(response.decode("utf-8"))["num"]
     xkcd.cur_max_comic = max_comic
     output = xkcd.command_update()
     expected_output = "No new comics.\n"
     self.assertEqual(output, expected_output)
Exemplo n.º 3
0
 def test_update_search_db(self):
     xkcd.cur_max_comic = 1
     xkcd.command_update()
     old_titles_loc = xkcd.titles_location
     old_transcripts_loc = xkcd.transcripts_location
     xkcd.titles_location = "test.txt"
     xkcd.transcripts_location = "test2.txt"
     fd = open("test.txt", "w")
     fd.write(str(xkcd.cur_max_comic - 1))
     fd.write(":'Test'\n")
     fd.close()
     fd = open("test2.txt", "w")
     fd.write(str(xkcd.cur_max_comic - 1))
     fd.write(":'Test'\n")
     fd.close()
     output = xkcd.command_update("search_db")
     expected_output = "No new comics.\n1 comics not in title database " "found."
     xkcd.titles_location = old_titles_loc
     xkcd.transcripts_location = old_transcripts_loc
     os.remove("test.txt")
     os.remove("test2.txt")
     self.assertEqual(output, expected_output)
Exemplo n.º 4
0
 def test_command_update(self):
     xkcd.cur_max_comic = 1000
     output = xkcd.command_update()
     generic_output = " new comics!\n"
     self.assertEqual(output[-13:], generic_output)