financeager icon indicating copy to clipboard operation
financeager copied to clipboard

Changed period into abstract class and moved docstrings

Open cardinalion opened this issue 6 years ago • 9 comments

cardinalion avatar Oct 11 '19 03:10 cardinalion

Already passed the pre-commit test. Not sure why the build failed

cardinalion avatar Oct 11 '19 16:10 cardinalion

Did you have a look at the build log? You can do so by clicking 'Details'.

pylipp avatar Oct 11 '19 17:10 pylipp

Did you have a look at the build log? You can do so by clicking 'Details'.

TypeError: Can't instantiate abstract class Period with abstract methods add_entry, get_entries, get_entry, remove_entry, update_entry

def test_default_name(self):
        period = Period()
        year = dt.date.today().year
        self.assertEqual(period.year, year)
        self.assertEqual(period.name, str(year))

I'm not sure how to test an abstract class. Should I delete this function?

cardinalion avatar Oct 11 '19 20:10 cardinalion

Ah that's tricky. Have a look at this (I found it by googling for 'python test abstract class method'). This means you could do

Period.__abstractmethods__ = set()
period = Period()

pylipp avatar Oct 12 '19 08:10 pylipp

Coverage Status

Coverage increased (+0.004%) to 99.577% when pulling c7cea258df90c7bd4007f5becdca13a0b6ecf7d7 on cardinalion:period-new into 50aed57980d48ffbbb4813cdc9c45e9efdb2ae50 on pylipp:master.

coveralls avatar Oct 12 '19 17:10 coveralls

Can you rebase this onto master?

pylipp avatar Oct 12 '19 22:10 pylipp

Can you also move the methods _preprocess_entry, _remove_redundant_fields, _validate_entry, and _substitute_none_fields and _convert_fields to Period? (sorry for blowing this up so much :))

pylipp avatar Oct 12 '19 22:10 pylipp

Can you also move the methods _preprocess_entry, _remove_redundant_fields, _validate_entry, and _substitute_none_fields and _convert_fields to Period? (sorry for blowing this up so much :))

Do you mean cut and copy these methods into Period class? Should I keep the staticmethod decorators?

cardinalion avatar Oct 12 '19 22:10 cardinalion

I noticed that the change is still a bit trickier... I'd like to have the methods of Period run validation of passed parameters (e.g. for add_entry()), such that methods in derived Period classes can re-use it via super() - so I'm not merging it yet.

pylipp avatar Oct 26 '19 22:10 pylipp