Ejemplo n.º 1
0
    def test_to_snow_unknown_value_handler_is_invoked(self, mocker):
        mock_handler = mocker.Mock()
        mapper = utils.PayloadMapper(dict(a=[(1, "a1")]), mock_handler.warn)
        mapper.to_snow(dict(a=2))

        mock_handler.warn.assert_called_once_with(
            "Encountered unknown value 2 while mapping field a.")
Ejemplo n.º 2
0
    def test_map_query_values(self):
        mapper = utils.PayloadMapper(dict(state=[("1", "new")]), None)

        result = query.map_query_values(
            [
                {
                    "caller": ("=", "abel.tuter"),
                    "state": ("=", "new")
                },
                {
                    "caller": ("=", "bertie.luby"),
                    "state": ("=", "new")
                },
            ],
            mapper,
        )

        assert result == [
            {
                "caller": ("=", "abel.tuter"),
                "state": ("=", "1")
            },
            {
                "caller": ("=", "bertie.luby"),
                "state": ("=", "1")
            },
        ]
Ejemplo n.º 3
0
    def test_to_ansible_is_inverse_of_to_snow(self, data):
        mapper = utils.PayloadMapper(
            dict(a=[(1, "a1"), (2, "a2")], b=[(2, "b2")]))

        assert data == mapper.to_snow(mapper.to_ansible(data))
Ejemplo n.º 4
0
    def test_to_snow_unknown_value_is_included(self):
        mapper = utils.PayloadMapper(dict(a=[(1, "a1")]))

        assert dict(a="a2") == mapper.to_snow(dict(a="a2"))
Ejemplo n.º 5
0
    def test_to_snow(self):
        mapper = utils.PayloadMapper(dict(a=[(1, 2), (3, 4)], b=[(5, 6)]))

        assert dict(a=1, b=5, c=7) == mapper.to_snow(dict(a=2, b=6, c=7))
Ejemplo n.º 6
0
    def test_to_ansible_unknown_value_is_included(self):
        mapper = utils.PayloadMapper(dict(a=[(1, "a1")]))

        assert dict(a=2) == mapper.to_ansible(dict(a=2))
Ejemplo n.º 7
0
    def test_to_ansible(self):
        mapper = utils.PayloadMapper(dict(a=[(1, 2), (3, 4)], b=[(5, 6)]))

        assert dict(a=4, b=6, c=7) == mapper.to_ansible(dict(a=3, b=5, c=7))