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([])

        WLN_URL = "https://www.wlnupdates.com/series-id/42758/emperors-domination"
        novelupdates_URL = "https://www.novelupdates.com/series/genius-detective/"

        self._not_up_to_date_URLS = [{
            "URL": WLN_URL,
            "latestChapter": "ch. 3000.0"
        }, {
            "URL": novelupdates_URL,
            "latestChapter": "c100"
        }]

        self._up_to_date_URLS = [{
            "URL":
            WLN_URL,
            "latestChapter":
            self.model._get_Latest_Chapter_URL_Filtered(WLN_URL)
        }, {
            "URL":
            novelupdates_URL,
            "latestChapter":
            self.model._get_Latest_Chapter_URL_Filtered(novelupdates_URL)
        }]
Пример #2
0
    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"}])
Пример #3
0
    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([])
Пример #4
0
class TestSetEmail(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_set_correct_email(self):
        # Note: no need to check for bad values because it won't break program
        # User can just enter in new email value
        email = "*****@*****.**"
        self.model.setEmail(email)

        self.assertEqual(email, self.model.getEmail())
        self.model._load_email()
        self.assertEqual(email, self.model.getEmail())
Пример #5
0
class TestGetLatestChapterURLFiltered(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_WLN_URL_without_series_id(self):
        URL = "https://www.wlnupdates.com/"
        self.assertEqual(None,
                         self.model._get_Latest_Chapter_URL_Filtered(URL))

    def test_novelupdates_URL_without_series(self):
        URL = "https://www.novelupdates.com/"
        self.assertEqual(None,
                         self.model._get_Latest_Chapter_URL_Filtered(URL))

    def test_correct_WLN_URL(self):
        URL = "https://www.wlnupdates.com/series-id/91919/treeincarnation"
        self.assertEqual("ch. 3.0",
                         self.model._get_Latest_Chapter_URL_Filtered(URL))

    def test_correct_novelupdates_URL(self):
        URL = "https://www.novelupdates.com/series/smiling-proud-wanderer/"
        self.assertEqual("c1-40",
                         self.model._get_Latest_Chapter_URL_Filtered(URL))

    def test_different_integer_input(self):
        for i in range(5):
            with self.assertRaises(TypeError):
                self.assertEqual(
                    None, self.model._get_Latest_Chapter_URL_Filtered(i))

    def test_wrong_string_input(self):
        test_input = "awdanodanwdiondwaindo"
        self.assertEqual(
            None, self.model._get_Latest_Chapter_URL_Filtered(test_input))
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())
Пример #7
0
class TestSetPassword(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_set_password(self):
        # Note: no need to check for bad values because it won't break program
        # User can just enter in new password value
        password = "******"
        self.model.setPassword(password)
        self.assertEqual(password, self.model.getPassword())
Пример #8
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())
Пример #9
0
class TestIntegrateUpdatedURLS(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_input_of_updated_URLS(self):
        updated_URLS = ["https://www.wlnupdates.com/series-id/2697/chaotic-sword-god", "https://www.novelupdates.com/series/yu-ren/"]

        advanced_result = """"""
        for url in updated_URLS:
            advanced_result += f"""{url}\n"""

        self.assertEqual(advanced_result, self.model._integrate_Updated_URLS(updated_URLS))

    def test_empty_list_input(self):
        empty = []

        basic_result = """"""

        self.assertEqual(basic_result, self.model._integrate_Updated_URLS(empty))
Пример #10
0
 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([])
Пример #11
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())
class TestCompileUpdatedURLS(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([])

        WLN_URL = "https://www.wlnupdates.com/series-id/42758/emperors-domination"
        novelupdates_URL = "https://www.novelupdates.com/series/genius-detective/"

        self._not_up_to_date_URLS = [{
            "URL": WLN_URL,
            "latestChapter": "ch. 3000.0"
        }, {
            "URL": novelupdates_URL,
            "latestChapter": "c100"
        }]

        self._up_to_date_URLS = [{
            "URL":
            WLN_URL,
            "latestChapter":
            self.model._get_Latest_Chapter_URL_Filtered(WLN_URL)
        }, {
            "URL":
            novelupdates_URL,
            "latestChapter":
            self.model._get_Latest_Chapter_URL_Filtered(novelupdates_URL)
        }]
        # No need to check for bad input
        # Not possible within the object/file unless manually set using _set_URL_data

    def test_not_up_to_date(self):
        self.model._set_URL_data(self._not_up_to_date_URLS)
        result = [
            "https://www.wlnupdates.com/series-id/42758/emperors-domination",
            "https://www.novelupdates.com/series/genius-detective/"
        ]
        self.assertEqual(result, self.model._compile_updated_URLS())

    def test_up_to_date(self):
        self.model._set_URL_data(self._up_to_date_URLS)
        result = []
        self.assertEqual(result, self.model._compile_updated_URLS())
Пример #13
0
class TestLoadEmail(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_load_email(self):
        # set the string to obj/file
        self.model.setEmail("*****@*****.**")
        # Reload email info and check that it's the same
        self.model._load_email()
        self.assertEqual("*****@*****.**", self.model.getEmail())

    def test_load_wrong_input_string(self):
        # set the string to obj/file
        self.model.setEmail("wadafgagwafgafwafa")
        # Reload email info and check that it's the same
        self.model._load_email()
        self.assertEqual("wadafgagwafgafwafa", self.model.getEmail())
Пример #14
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())