Ejemplo n.º 1
0
class TestDeleteURLData(unittest.TestCase):
    def setUp(self):
        self.model = NovelAlertsModel(print, "tests/unit/fixtures/testing_URL_log.csv", "tests/unit/fixtures/testing_email.txt")
        self.model.setEmail("")

        # No need to check if in object/file because _set_URL_data saves to both
        self.model._set_URL_data([{"URL": "https://www.wlnupdates.com/series-id/42758/emperors-domination", "latestChapter": "ch. 3463.0"}, 
                                    {"URL": "https://www.novelupdates.com/series/genius-detective/", "latestChapter": "c572"}])
          
    def test_delete_WLN_URL(self):
        URL = "https://www.wlnupdates.com/series-id/42758/emperors-domination"
        dict_row = {"URL": URL, "latestChapter": self.model._get_Latest_Chapter_URL_Filtered(URL)}

        # Delete from object/file
        self.model.deleteURLData(URL)

        # Check not in object
        self.assertNotIn(dict_row, self.model._get_URL_data())
        # Check not in file
        self.model._load_URL_Data()
        self.assertNotIn(dict_row, self.model._get_URL_data())

    def test_delete_novelupdates_URL(self):
        URL = "https://www.novelupdates.com/series/genius-detective/"
        dict_row = {"URL": URL, "latestChapter": self.model._get_Latest_Chapter_URL_Filtered(URL)}

        # Delete from object/file
        self.model.deleteURLData(URL)

        # Check not in object
        self.assertNotIn(dict_row, self.model._get_URL_data())
        # Check not in file
        self.model._load_URL_Data()
        self.assertNotIn(dict_row, self.model._get_URL_data())
Ejemplo n.º 2
0
class TestAddURLData(unittest.TestCase):
    def setUp(self):
        self.model = NovelAlertsModel(
            print, "tests/unit/fixtures/testing_URL_log.csv",
            "tests/unit/fixtures/testing_email.txt")
        self.model.setEmail("")

        # No need to check if in file or object since _set_URL_data saves new data to both
        self.model._set_URL_data([])

    def test_add_correct_WLN_URL(self):
        URL = "https://www.wlnupdates.com/series-id/91919/treeincarnation"
        dict_row = {
            "URL": URL,
            "latestChapter": self.model._get_Latest_Chapter_URL_Filtered(URL)
        }

        # Adds data to object and file
        self.model.addURLData(URL)

        # Check if in object
        self.assertIn(dict_row, self.model._get_URL_data())
        # Check if in file
        self.model._load_URL_Data()
        self.assertIn(dict_row, self.model._get_URL_data())

    def test_add_correct_novelupdates_URL(self):
        URL = "https://www.novelupdates.com/series/smiling-proud-wanderer/"
        dict_row = {
            "URL": URL,
            "latestChapter": self.model._get_Latest_Chapter_URL_Filtered(URL)
        }

        # Adds data to object and file
        self.model.addURLData(URL)

        # Check if in object
        self.assertIn(dict_row, self.model._get_URL_data())
        # Check if in file
        self.model._load_URL_Data()
        self.assertIn(dict_row, self.model._get_URL_data())

    def test_add_integer_input(self):
        for i in range(5):
            with self.assertRaises(TypeError):
                self.model.addURLData(i)
                self.assertNotIn(i, self.model._get_URL_data())

    def test_add_wrong_string_input(self):
        test_input = "awdanodanwdiondwaindo"
        self.model.addURLData(test_input)
        self.assertNotIn(test_input, self.model._get_URL_data())
class TestWriteURLDataToFile(unittest.TestCase):
    def setUp(self):
        self.model = NovelAlertsModel(
            print, "tests/unit/fixtures/testing_URL_log.csv",
            "tests/unit/fixtures/testing_email.txt")
        self.model.setEmail("")
        self.model._set_URL_data([])

    def test_write_URL_data_to_file(self):
        URL_data = [{
            "URL":
            "https://www.wlnupdates.com/series-id/42758/emperors-domination",
            "latestChapter": "ch. 3463.0"
        }, {
            "URL": "https://www.novelupdates.com/series/genius-detective/",
            "latestChapter": "c572"
        }]
        self.model._set_URL_data(URL_data)

        self.model._write_URL_data_to_file()
        self.assertEqual(URL_data, self.model._get_URL_data())
Ejemplo n.º 4
0
class TestLoadURLData(unittest.TestCase):
    def setUp(self):
        self.model = NovelAlertsModel(
            print, "tests/unit/fixtures/testing_URL_log.csv",
            "tests/unit/fixtures/testing_email.txt")
        self.model.setEmail("")
        self.model._set_URL_data([])

    def test_loading_of_URL_data(self):
        URL_data = [{
            "URL":
            "https://www.wlnupdates.com/series-id/42758/emperors-domination",
            "latestChapter": "ch. 3463.0"
        }, {
            "URL": "https://www.novelupdates.com/series/genius-detective/",
            "latestChapter": "c572"
        }]

        # Set new URL data to obj/file and reload to check that value is the same
        self.model._set_URL_data(URL_data)
        self.model._load_URL_Data()
        self.assertEqual(URL_data, self.model._get_URL_data())