diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2021-05-17 08:13:22 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2021-05-17 08:13:22 +0100 |
commit | a5b4f46b55ee39409126da978677f54e271060c1 (patch) | |
tree | fd8d7afc460479efb3220fcf5c61f38d0dc9d91d | |
parent | e3f26229d0f69ddb93b866e184626337c30778c2 (diff) |
refactorings
-rw-r--r-- | datamaps/api/api.py | 1 | ||||
-rw-r--r-- | datamaps/core/temporal.py | 15 | ||||
-rw-r--r-- | datamaps/tests/test_api.py | 7 |
3 files changed, 13 insertions, 10 deletions
diff --git a/datamaps/api/api.py b/datamaps/api/api.py index 6fcf4cf..b6d8025 100644 --- a/datamaps/api/api.py +++ b/datamaps/api/api.py @@ -14,6 +14,7 @@ def project_data_from_master_api(master_file: str, quarter: int, year: int): m = Master(Quarter(quarter, year), master_file) return m + def project_data_from_master_month_api(master_file: str, month: int, year: int): """Create a Master object directly without the need to explicitly pass a Month object. diff --git a/datamaps/core/temporal.py b/datamaps/core/temporal.py index 24a0d70..f97edfa 100644 --- a/datamaps/core/temporal.py +++ b/datamaps/core/temporal.py @@ -32,9 +32,13 @@ class Month: @property def end_date(self): if self._month_int == 2 and calendar.isleap(self.year): - return datetime.date(self.year, self._month_int, Month._end_ints[self._month_int] + 1) + return datetime.date( + self.year, self._month_int, Month._end_ints[self._month_int] + 1 + ) else: - return datetime.date(self.year, self._month_int, Month._end_ints[self._month_int]) + return datetime.date( + self.year, self._month_int, Month._end_ints[self._month_int] + ) @property def name(self): @@ -112,8 +116,10 @@ class FinancialYear: class Quarter: - """An object representing a financial quarter. This is mainly required for building - a :py:class:`core.master.Master` object. + """An object representing a financial quarter. + + This is mainly required for building a :py:class:`core.master.Master` + object. Args: quarter (int): e.g.1, 2, 3 or 4 @@ -166,7 +172,6 @@ class Quarter: year = self.year self.months.append(Month(m, year)) - def __str__(self): return f"Q{self.quarter} {str(self.year)[2:]}/{str(self.year + 1)[2:]}" diff --git a/datamaps/tests/test_api.py b/datamaps/tests/test_api.py index e3f3515..ecb30ac 100644 --- a/datamaps/tests/test_api.py +++ b/datamaps/tests/test_api.py @@ -1,8 +1,7 @@ import datetime -import pytest from ..api import project_data_from_master, project_data_from_master_month -from ..core.temporal import Quarter, Month +from ..core.temporal import Month def test_get_project_data(master): @@ -19,9 +18,7 @@ def test_get_project_data_using_month(master): m2 = project_data_from_master_month(master, 8, 2021) m3 = project_data_from_master_month(master, 9, 2021) m4 = project_data_from_master_month(master, 10, 2021) - assert ( - m["Chutney Bridge.xlsm"]["Project/Programme Name"] == "Chutney Bridge Ltd" - ) + assert m["Chutney Bridge.xlsm"]["Project/Programme Name"] == "Chutney Bridge Ltd" assert isinstance(m.month, Month) assert m.month.name == "July" assert m2.month.name == "August" |