Example #1
0
    def test_read_month_data_file_available(self):
        paths = {DATA_FILES_PATH_KEYWORD: self.data_directory}

        test_date = date(2020, 1, 1)
        mock_data = {1: {"PyCharm": 20000, "IntelliJ": 5000}}

        file_name = "01-2020.json"
        with open(self.data_directory.joinpath(file_name), "w") as file:
            file.write(json.dumps(mock_data))

        data_backend = DataBackend(paths)
        result = data_backend.read_month_data(test_date)
        self.assertDictEqual(mock_data, result)
Example #2
0
    def test_read_month_data_file_not_available(self):
        paths = {DATA_FILES_PATH_KEYWORD: Path("/Some/Invalid/Path")}

        data_backend = DataBackend(paths)
        result = data_backend.read_month_data(date(2020, 1, 1))
        self.assertDictEqual(result, {})