def test_remote_and_desired_equal_check(self, mocker): client = mocker.Mock() client.get.return_value = http.Response(200, '{}') changed, object = tessen.sync(client, "/path", {}, True) assert changed is False assert object == {}
def test_remote_and_desired_not_equal_check(self, mocker): client = mocker.Mock() client.get.return_value = http.Response(200, '{"opt_out": "false"}') changed, object = tessen.sync(client, "/path", {'opt_out': True}, True) assert changed is True assert object == {'opt_out': True} client.put.assert_not_called()
def test_remote_and_desired_not_equal(self, mocker): client = mocker.Mock() client.get.side_effect = ( http.Response(200, '{"opt_out": "false"}'), http.Response(200, '{"opt_out": "true"}'), ) client.put.return_value = http.Response(200, "") changed, object = tessen.sync(client, "/path", {'opt_out': True}, False) assert changed is True assert object == {'opt_out': 'true'} client.put.assert_called_once_with("/path", {'opt_out': True})