Beispiel #1
0
    def test_csv_rename(self, site_mock, base_init_mock, browser_mock):  # pylint: disable=too-many-arguments
        parser = MovielensRatingsParser(None)
        parser.movies = []
        parser.site = site_mock
        parser.site.site_name = 'Movielens'
        parser.site.browser = browser_mock
        parser.exports_folder = os.path.abspath(os.path.join(TESTDATA_PATH, 'exports'))
        parser.csv_filename = '1234567890_movielens.csv'

        self.assertFalse(os.path.isfile(os.path.join(TESTDATA_PATH, 'exports', 'movielens-ratings.csv')))
        with open(os.path.join(TESTDATA_PATH, 'exports', 'movielens-ratings.csv'), 'w+'):
            self.assertTrue(os.path.isfile(os.path.join(TESTDATA_PATH, 'exports', 'movielens-ratings.csv')))
        self.assertFalse(os.path.isfile(os.path.join(TESTDATA_PATH, 'exports', parser.csv_filename)))

        parser._rename_csv_file('movielens-ratings.csv')  # pylint: disable=protected-access

        self.assertFalse(os.path.isfile(os.path.join(TESTDATA_PATH, 'exports', 'movielens-ratings.csv')))
        self.assertTrue(os.path.isfile(os.path.join(TESTDATA_PATH, 'exports', parser.csv_filename)))
        os.remove(os.path.join(TESTDATA_PATH, 'exports', parser.csv_filename))
    def test_csv_rename(self, site_mock, base_init_mock, browser_mock):  # pylint: disable=too-many-arguments
        parser = MovielensRatingsParser(None)
        parser.movies = []
        parser.site = site_mock
        parser.site.site_name = "Movielens"
        parser.site.browser = browser_mock
        parser.exports_folder = os.path.abspath(
            os.path.join(TESTDATA_PATH, "exports"))
        parser.csv_filename = "1234567890_movielens.csv"
        parser.downloaded_file_name = os.path.join(os.pardir, "movielens",
                                                   "my_ratings.csv")

        self.assertFalse(
            os.path.isfile(
                os.path.join(TESTDATA_PATH, "exports",
                             "movielens-ratings.csv")))
        with open(
                os.path.join(TESTDATA_PATH, "exports",
                             "movielens-ratings.csv"), "w+"):
            self.assertTrue(
                os.path.isfile(
                    os.path.join(TESTDATA_PATH, "exports",
                                 "movielens-ratings.csv")))
        self.assertFalse(
            os.path.isfile(
                os.path.join(TESTDATA_PATH, "exports", parser.csv_filename)))

        parser._rename_csv_file("movielens-ratings.csv")  # pylint: disable=protected-access

        self.assertFalse(
            os.path.isfile(
                os.path.join(TESTDATA_PATH, "exports",
                             "movielens-ratings.csv")))
        self.assertTrue(
            os.path.isfile(
                os.path.join(TESTDATA_PATH, "exports", parser.csv_filename)))
        os.remove(os.path.join(TESTDATA_PATH, "exports", parser.csv_filename))