code: def test_format_date(api):
      assert (
          format_query_date(datetime(2015, 1, 1))
          == "2015-01-01T00:00:00Z"
      )
      assert (
          format_query_date(date(2015, 1, 1)) == "2015-01-01T00:00:00Z"
      )
      assert (
          format_query_date("2015-01-01T00:00:00Z")
          == "2015-01-01T00:00:00Z"
      )
      assert format_query_date("20150101") == "2015-01-01T00:00:00Z"
      assert format_query_date(" NOW ") == "NOW"
      assert format_query_date(None) == "*"
  
      for date_str in (
          "NOW",
          "NOW-1DAY",
          "NOW-1DAYS",
          "NOW-500DAY",
          "NOW-500DAYS",
          "NOW-2MONTH",
          "NOW-2MONTHS",
          "NOW-20MINUTE",
          "NOW-20MINUTES",
          "NOW+10HOUR",
          "2015-01-01T00:00:00Z+1DAY",
          "NOW+3MONTHS-7DAYS/DAYS",
          "*",
      ):
          assert format_query_date(date_str) == date_str
          api.query(
              raw="ingestiondate:[{} TO *]".format(date_str), limit=0
          )
  
      for date_str in (
          "NOW - 1HOUR",
          "NOW -   1HOURS",
          "NOW-1 HOURS",
          "NOW-1",
          "NOW-",
          "**",
          "+",
          "-",
      ):
          with pytest.raises(ValueError):
              format_query_date(date_str)
          with pytest.raises(QuerySyntaxError):
              api.query(
                  raw="ingestiondate:[{} TO *]".format(date_str),
                  limit=0,
              )
  
imports: from contextlib import contextmanager
  from datetime import datetime, date, timedelta
  import pytest
  import requests_mock
  from requests.exceptions import StreamConsumedError, ContentDecodingError, InvalidProxyURL, InvalidHeader, TooManyRedirects, ReadTimeout, SSLError
  from sentinelsat import format_query_date, SentinelAPI
  from sentinelsat.exceptions import QuerySyntaxError, QueryLengthError, UnauthorizedError
  from sentinelsat.sentinel import _format_order_by
label_desc: Use image node_id 1 for calling a global function with example usage: test_format_date(api) without return types