2021-03-05 11:42:07 +01:00
|
|
|
import pytest
|
2021-10-18 19:44:29 +00:00
|
|
|
import sure # noqa # pylint: disable=unused-import
|
2015-11-27 14:14:40 -05:00
|
|
|
from freezegun import freeze_time
|
|
|
|
|
2019-10-31 08:44:26 -07:00
|
|
|
from moto.core.utils import (
|
|
|
|
camelcase_to_underscores,
|
|
|
|
underscores_to_camelcase,
|
|
|
|
unix_time,
|
2021-03-05 11:42:07 +01:00
|
|
|
camelcase_to_pascal,
|
|
|
|
pascal_to_camelcase,
|
2019-10-31 08:44:26 -07:00
|
|
|
)
|
2015-11-23 14:04:14 +01:00
|
|
|
|
|
|
|
|
2021-03-05 11:42:07 +01:00
|
|
|
@pytest.mark.parametrize(
|
2021-10-18 19:44:29 +00:00
|
|
|
"_input,expected",
|
2021-03-05 11:42:07 +01: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):
|
|
|
|
camelcase_to_underscores(_input).should.equal(expected)
|
2021-03-05 11:42:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2021-10-18 19:44:29 +00:00
|
|
|
"_input,expected",
|
2022-03-10 13:39:59 -01:00
|
|
|
[("the_new_attribute", "theNewAttribute"), ("attribute", "attribute")],
|
2021-03-05 11:42:07 +01:00
|
|
|
)
|
2021-10-18 19:44:29 +00:00
|
|
|
def test_underscores_to_camelcase(_input, expected):
|
|
|
|
underscores_to_camelcase(_input).should.equal(expected)
|
2015-11-23 14:09:31 +01:00
|
|
|
|
|
|
|
|
2021-03-05 11:42:07 +01:00
|
|
|
@pytest.mark.parametrize(
|
2021-10-18 19:44:29 +00:00
|
|
|
"_input,expected",
|
2022-03-10 13:39:59 -01:00
|
|
|
[("TheNewAttribute", "theNewAttribute"), ("Attribute", "attribute")],
|
2021-03-05 11:42:07 +01:00
|
|
|
)
|
2021-10-18 19:44:29 +00:00
|
|
|
def test_pascal_to_camelcase(_input, expected):
|
|
|
|
pascal_to_camelcase(_input).should.equal(expected)
|
2021-03-05 11:42:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2021-10-18 19:44:29 +00:00
|
|
|
"_input,expected",
|
2022-03-10 13:39:59 -01:00
|
|
|
[("theNewAttribute", "TheNewAttribute"), ("attribute", "Attribute")],
|
2021-03-05 11:42:07 +01:00
|
|
|
)
|
2021-10-18 19:44:29 +00:00
|
|
|
def test_camelcase_to_pascal(_input, expected):
|
|
|
|
camelcase_to_pascal(_input).should.equal(expected)
|
2015-11-27 14:14:40 -05:00
|
|
|
|
|
|
|
|
|
|
|
@freeze_time("2015-01-01 12:00:00")
|
|
|
|
def test_unix_time():
|
|
|
|
unix_time().should.equal(1420113600.0)
|