Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_datetime():
formatter = PorcelainFormatter()
expected = datetime(2017, 3, 6, 23, 22, 21, 610429, tzinfo=pytz.UTC)
assert formatter.parse_datetime(1488842541.610429) == expected
assert formatter.parse_datetime(None) is None
assert formatter.parse_datetime('') is None
def test_format_datetime():
formatter = PorcelainFormatter()
dt = datetime(2017, 3, 8, 0, 0, 17, 457955, tzinfo=pytz.UTC)
t = 1488931217
assert formatter.format_datetime(dt) == t
def test_formatting_parsing_consitency():
tz = pytz.timezone('CET')
dt = datetime(2017, 3, 8, 21, 6, 19).replace(tzinfo=tz)
formatter = PorcelainFormatter(tz_override=tz)
assert formatter.parse_datetime(formatter.format_datetime(dt)) == dt
def test_simple_action(todo_factory):
formatter = PorcelainFormatter()
todo = todo_factory(id=7, location='Downtown')
expected = {
"completed": False,
"due": None,
"id": 7,
"list": "default",
"location": "Downtown",
"percent": 0,
"priority": 0,
"summary": "YARR!"
}
assert formatter.simple_action('Delete', todo) == \
json.dumps(expected, indent=4, sort_keys=True)
def callback(click_ctx, color, porcelain, humanize):
ctx = click_ctx.ensure_object(AppContext)
if porcelain and humanize:
raise click.ClickException('--porcelain and --humanize cannot be used'
' at the same time.')
if humanize is None: # False means explicitly disabled
humanize = ctx.config['main']['humanize']
if humanize:
ctx.formatter_class = formatters.HumanizedFormatter
elif porcelain:
ctx.formatter_class = formatters.PorcelainFormatter
else:
ctx.formatter_class = formatters.DefaultFormatter
color = color or ctx.config['main']['color']
if color == 'always':
click_ctx.color = True
elif color == 'never':
click_ctx.color = False
paths = [
path for path in glob.iglob(expanduser(ctx.config["main"]["path"]))
if isdir(path)
]
if len(paths) == 0:
raise exceptions.NoListsFound(ctx.config["main"]["path"])