2021-03-05 10:42:07 +00:00
|
|
|
import pytest
|
2015-11-27 19:14:40 +00:00
|
|
|
from freezegun import freeze_time
|
|
|
|
|
|
|
|
from moto.core.utils import (
|
|
|
|
camelcase_to_underscores,
|
|
|
|
underscores_to_camelcase,
|
|
|
|
unix_time,
|
2021-03-05 10:42:07 +00:00
|
|
|
camelcase_to_pascal,
|
|
|
|
pascal_to_camelcase,
|
2019-10-31 15:44:26 +00:00
|
|
|
)
|
2015-11-23 13:04:14 +00:00
|
|
|
|
|
|
|
|
2021-03-05 10:42:07 +00:00
|
|
|
@pytest.mark.parametrize(
|
2021-10-18 19:44:29 +00:00
|
|
|
"_input,expected",
|
2021-03-05 10:42:07 +00:00
|
|
|
[
|
|
|
|
("theNewAttribute", "the_new_attribute"),
|
|
|
|
("attri bute With Space", "attribute_with_space"),
|
|
|
|
("FirstLetterCapital", "first_letter_capital"),
|
|
|
|
("ListMFADevices", "list_mfa_devices"),
|
|
|
|
],
|
|
|
|
)
|
2021-10-18 19:44:29 +00:00
|
|
|
def test_camelcase_to_underscores(_input, expected):
|
2023-07-10 21:04:31 +00:00
|
|
|
assert camelcase_to_underscores(_input) == expected
|
2021-03-05 10:42:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2021-10-18 19:44:29 +00:00
|
|
|
"_input,expected",
|
2021-03-05 10:42:07 +00:00
|
|
|
[("the_new_attribute", "theNewAttribute"), ("attribute", "attribute")],
|
|
|
|
)
|
2021-10-18 19:44:29 +00:00
|
|
|
def test_underscores_to_camelcase(_input, expected):
|
2023-07-10 21:04:31 +00:00
|
|
|
assert underscores_to_camelcase(_input) == expected
|
2015-11-23 13:09:31 +00:00
|
|
|
|
|
|
|
|
2021-03-05 10:42:07 +00:00
|
|
|
@pytest.mark.parametrize(
|
2021-10-18 19:44:29 +00:00
|
|
|
"_input,expected",
|
2021-03-05 10:42:07 +00:00
|
|
|
[("TheNewAttribute", "theNewAttribute"), ("Attribute", "attribute")],
|
|
|
|
)
|
2021-10-18 19:44:29 +00:00
|
|
|
def test_pascal_to_camelcase(_input, expected):
|
2023-07-10 21:04:31 +00:00
|
|
|
assert pascal_to_camelcase(_input) == expected
|
2021-03-05 10:42:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2021-10-18 19:44:29 +00:00
|
|
|
"_input,expected",
|
2021-03-05 10:42:07 +00:00
|
|
|
[("theNewAttribute", "TheNewAttribute"), ("attribute", "Attribute")],
|
|
|
|
)
|
2021-10-18 19:44:29 +00:00
|
|
|
def test_camelcase_to_pascal(_input, expected):
|
2023-07-10 21:04:31 +00:00
|
|
|
assert camelcase_to_pascal(_input) == expected
|
2015-11-27 19:14:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
@freeze_time("2015-01-01 12:00:00")
|
|
|
|
def test_unix_time():
|
2023-07-10 21:04:31 +00:00
|
|
|
assert unix_time() == 1420113600.0
|