Changeset - 99f97d3f5849
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-03-05 17:23:03
brettcsmith@brettcsmith.org
expenseAllocation: Accept 'admin' shorthand for 'administration'.
2 files changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/plugin/meta_expense_allocation.py
Show inline comments
...
 
@@ -14,17 +14,19 @@
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 

	
 
import enum
 

	
 
from . import core
 

	
 
class ExpenseAllocations(enum.Enum):
 
    administration = 'administration'
 
    fundraising = 'fundraising'
 
    program = 'program'
 

	
 
    admin = administration
 

	
 

	
 
class MetaExpenseAllocation(core.PostingChecker):
 
    ACCOUNTS = ('Expenses:',)
 
    METADATA_KEY = 'expenseAllocation'
 
    VALUES_ENUM = ExpenseAllocations
tests/test_meta_expenseAllocation.py
Show inline comments
...
 
@@ -15,24 +15,25 @@
 
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 

	
 
import pytest
 

	
 
from . import testutil
 

	
 
from conservancy_beancount.plugin import meta_expense_allocation
 

	
 
VALID_VALUES = {
 
    'program': 'program',
 
    'administration': 'administration',
 
    'fundraising': 'fundraising',
 
    'admin': 'administration',
 
}
 

	
 
INVALID_VALUES = {
 
    'invalid',
 
    '',
 
}
 

	
 
@pytest.mark.parametrize('src_value,set_value', VALID_VALUES.items())
 
def test_valid_values_on_postings(src_value, set_value):
 
    txn = testutil.Transaction(postings=[
 
        ('Assets:Cash', -25),
 
        ('Expenses:General', 25, {'expenseAllocation': src_value}),
0 comments (0 inline, 0 general)