예제 #1
0
    def test_should_raise_an_exception_if_a_provided_custom_mapper_contains_errors(
            self):
        """... it should raise an exception if a provided custom mapper contains errors"""
        def custom_broken_mapper(_):
            raise Exception

        pr = PassReader(path="tests/password-store",
                        mapper=custom_broken_mapper)
        with pytest.raises(CustomMapperExecException):
            pr.parse_pass_entry("test1")
예제 #2
0
    def test_should_apply_the_mapper_when_provided(self):
        """... it should apply the mapper when provided"""
        def custom_mapper(entry: PassEntry) -> PassEntry:
            entry.title += "_modified"
            if 'cell_number' in entry.custom_properties:
                entry.custom_properties["cell_number"] = "11111111"
            return entry

        pr = PassReader(path="tests/password-store", mapper=custom_mapper)
        entry = pr.parse_pass_entry("test1")
        assert entry.title == "test1_modified"
        assert entry.custom_properties['cell_number'] == "11111111"