# Path: craft_ai/errors.py
# class CraftAiError(Exception):
# class CraftAiUnknownError(CraftAiError):
# class CraftAiNetworkError(CraftAiError):
# class CraftAiCredentialsError(CraftAiError):
# class CraftAiInternalError(CraftAiError):
# class CraftAiBadRequestError(CraftAiError):
# class CraftAiNotFoundError(CraftAiError):
# class CraftAiDecisionError(CraftAiError):
# class CraftAiNullDecisionError(CraftAiDecisionError):
# class CraftAiTimeError(CraftAiError):
# class CraftAiTokenError(CraftAiError):
# class CraftAiLongRequestTimeOutError(CraftAiError):
#     def __init__(self, message=None, metadata=None):
#     def __str__(self):
# 
# Path: craft_ai/formatters.py
# def format_property(property_type, value=None):
#     formatter = (
#         PROPERTY_FORMATTER[property_type]
#         if property_type in PROPERTY_FORMATTER
#         else PROPERTY_FORMATTER[TYPE_ANY]
#     )
# 
#     def extended_formatter(value):
#         if value is None:
#             return "null"
#         if value == {}:
#             return "N/A"
#         return formatter(value)
# 
#     if value is not None:
#         return extended_formatter(value)
# 
#     return extended_formatter
# 
# def format_decision_rules(rules):
#     return " and ".join([_format_decision_rule(rule) for rule in rules])


import unittest
import json
import os
from dateutil.parser import isoparse
from craft_ai import format_property, format_decision_rules, errors





class TestFormatter(unittest.TestCase):
    def test_format_property_time_of_day(self):
        formatter = format_property("time_of_day")

        self.assertEqual(formatter(11.5), "11:30")
        self.assertEqual(formatter(11.008), "11:00:28")

        self.assertEqual(formatter(isoparse("2016-10-20T08:20:03")), "08:20:03")
        self.assertEqual(formatter(isoparse("2016-08-12T13:37")), "13:37")

    def test_format_property_enum(self):
        formatter = format_property("enum")

        self.assertEqual(formatter("toto"), "toto")

    def test_format_property_continuous(self):

# Path: craft_ai/errors.py
# class CraftAiError(Exception):
# class CraftAiUnknownError(CraftAiError):
# class CraftAiNetworkError(CraftAiError):
# class CraftAiCredentialsError(CraftAiError):
# class CraftAiInternalError(CraftAiError):
# class CraftAiBadRequestError(CraftAiError):
# class CraftAiNotFoundError(CraftAiError):
# class CraftAiDecisionError(CraftAiError):
# class CraftAiNullDecisionError(CraftAiDecisionError):
# class CraftAiTimeError(CraftAiError):
# class CraftAiTokenError(CraftAiError):
# class CraftAiLongRequestTimeOutError(CraftAiError):
#     def __init__(self, message=None, metadata=None):
#     def __str__(self):
# 
# Path: craft_ai/formatters.py
# def format_property(property_type, value=None):
#     formatter = (
#         PROPERTY_FORMATTER[property_type]
#         if property_type in PROPERTY_FORMATTER
#         else PROPERTY_FORMATTER[TYPE_ANY]
#     )
# 
#     def extended_formatter(value):
#         if value is None:
#             return "null"
#         if value == {}:
#             return "N/A"
#         return formatter(value)
# 
#     if value is not None:
#         return extended_formatter(value)
# 
#     return extended_formatter
# 
# def format_decision_rules(rules):
#     return " and ".join([_format_decision_rule(rule) for rule in rules])


# Path: tests/test_formatters.py
import unittest
import json
import os
from dateutil.parser import isoparse
from craft_ai import format_property, format_decision_rules, errors






class TestFormatter(unittest.TestCase):
    def test_format_property_time_of_day(self):
        formatter = format_property("time_of_day")

        self.assertEqual(formatter(11.5), "11:30")
        self.assertEqual(formatter(11.008), "11:00:28")

        self.assertEqual(formatter(isoparse("2016-10-20T08:20:03")), "08:20:03")
        self.assertEqual(formatter(isoparse("2016-08-12T13:37")), "13:37")

    def test_format_property_enum(self):
        formatter = format_property("enum")

        self.assertEqual(formatter("toto"), "toto")

    def test_format_property_continuous(self):

        formatter = format_property("continuous")