def json_or_python_to_test_case(value, state=None):
            if value is None:
                return value, None
            if state is None:
                state = conv.default_state

            test_case = json_to_test_case.check_entities_and_role(
                value, self.tax_benefit_system, state)

            test_case, error, groupless_persons = json_to_test_case.check_entities_consistency(
                test_case, self.tax_benefit_system, state)
            if error is not None:
                return test_case, error

            # We try to attribute groupless individus to entities, according to rules defined by each country
            if repair:
                test_case = self.attribute_groupless_persons_to_entities(
                    test_case, period, groupless_persons)

            test_case, error = json_to_test_case.check_each_person_has_entities(
                test_case, self.tax_benefit_system, state)
            if error is not None:
                return test_case, error

            test_case, error = self.post_process_test_case(
                test_case, period, state)

            return test_case, error
Example #2
0
def test_ids_must_be_strings_or_ints():
    test_case = {
        'persons': [{
            'id': 0,
            'salary': 1
        }],
        'households': [{
            'id': {}
        }]
    }
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)
Example #3
0
def test_variables_must_be_set_for_the_right_entity():
    test_case = {
        'persons': [{
            'id': 0
        }],
        'households': [{
            'parents': 0,
            'salary': 1
        }]
    }
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)
Example #4
0
def test_entity_members_must_be_singleton_or_list():
    test_case = {
        'persons': [{
            'id': 0,
            'salary': 1
        }],
        'households': [{
            'parents': {}
        }]
    }
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)
Example #5
0
def test_variables_must_exist_in_tbs():
    test_case = {
        'persons': [{
            'id': 0,
            'salarrry': 1
        }],
        'households': [{
            'parents': 0
        }]
    }
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)
Example #6
0
def test_ids_must_not_be_set_to_None():
    test_case = {
        'persons': [{
            'id': None,
            'salary': 1
        }],
        'households': [{
            'id': None
        }]
    }
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)
Example #7
0
def test_entity_members_multiple_roles_should_be_casted_to_a_list():
    test_case = {
        'persons': [{
            'id': 0,
            'salary': 1
        }],
        'households': [{
            'parents': 0
        }]
    }
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)
    assert test_case['households'][0]['parents'] == [0]
Example #8
0
def test_ids_should_be_added_to_test_entities():
    test_case = {
        'persons': [{
            'id': 0,
            'salary': 1
        }],
        'households': [{
            'parents': ['0']
        }]
    }
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)
    assert test_case['households'][0].get('id') is not None
Example #9
0
def test_variables_values_must_be_valid():
    test_case = {
        'persons': [{
            'id': 0,
            'salary': {
                "nonsense": 10000
            }
        }],
        'households': [{
            'parents': 0
        }]
    }
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)
Example #10
0
def test_entities_lists_must_be_singleton_or_list_of_objects():
    test_case = {'persons': [[], []], 'households': [{'parents': ['0']}]}
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)
Example #11
0
def test_all_entities_should_be_set():
    test_case = {'persons': [{'id': 0, 'salary': 1}]}
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)
    assert test_case['households'] is not None
Example #12
0
def test_all_keys_must_be_valid_entity_names():
    test_case = {'unknown_entity': [{'id': 0, 'salary': 1}]}
    test_case = check_entities_and_role(test_case, tax_benefit_system, None)