Skip to content

Commit 352d1b6

Browse files
committed
📄 add license headers to test files
1 parent 96e5cce commit 352d1b6

File tree

3 files changed

+71
-18
lines changed

3 files changed

+71
-18
lines changed

tests/test_find_util.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
"""
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2021-present Pycord Development
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a
7+
copy of this software and associated documentation files (the "Software"),
8+
to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
and/or sell copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22+
DEALINGS IN THE SOFTWARE.
23+
"""
24+
125
import pytest
226
from discord.utils import find
327

tests/test_format_dt.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
"""
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2021-present Pycord Development
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a
7+
copy of this software and associated documentation files (the "Software"),
8+
to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
and/or sell copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22+
DEALINGS IN THE SOFTWARE.
23+
"""
24+
125
import datetime
226
import random
327
import pytest
@@ -28,10 +52,6 @@ def random_time():
2852
@pytest.mark.parametrize(("dt", "expected_ts"), DATETIME_CASES)
2953
@pytest.mark.parametrize("style", ALL_STYLES)
3054
def test_format_dt_formats_datetime(dt, expected_ts, style):
31-
"""
32-
For each (dt, expected_ts) pair and each style,
33-
format_dt should produce the correct Discord timestamp.
34-
"""
3555
if style is None:
3656
expected = f"<t:{expected_ts}>"
3757
else:
@@ -42,10 +62,6 @@ def test_format_dt_formats_datetime(dt, expected_ts, style):
4262

4363
@pytest.mark.parametrize("style", ALL_STYLES)
4464
def test_format_dt_formats_time_equivalence(style):
45-
"""
46-
For a time-only input, format_dt(time, style) should equal
47-
format_dt(datetime.combine(today, time), style).
48-
"""
4965
tm = random_time()
5066
today = datetime.datetime.now().date()
5167
result_time = format_dt(tm, style=style)

tests/test_snowflake_datetime.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
# tests/test_snowflake_utils.py
1+
"""
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2021-present Pycord Development
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a
7+
copy of this software and associated documentation files (the "Software"),
8+
to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
and/or sell copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22+
DEALINGS IN THE SOFTWARE.
23+
"""
224

325
import datetime
426
import pytest
@@ -18,48 +40,39 @@
1840

1941
@pytest.mark.parametrize(("dt", "expected_ms"), DATETIME_CASES)
2042
def test_generate_snowflake_realistic(dt, expected_ms):
21-
"""Realistic mode should set lower 22 bits to 0x3FFFFF."""
2243
sf = generate_snowflake(dt, mode="realistic")
23-
# top bits are the timestamp
2444
assert (sf >> 22) == expected_ms
25-
# lower 22 bits are all ones in realistic mode
2645
assert (sf & ((1 << 22) - 1)) == 0x3FFFFF
2746

2847

2948
@pytest.mark.parametrize(("dt", "expected_ms"), DATETIME_CASES)
3049
def test_generate_snowflake_boundary_low(dt, expected_ms):
31-
"""Boundary mode low should zero out lower 22 bits."""
3250
sf = generate_snowflake(dt, mode="boundary", high=False)
3351
assert (sf >> 22) == expected_ms
3452
assert (sf & ((1 << 22) - 1)) == 0
3553

3654

3755
@pytest.mark.parametrize(("dt", "expected_ms"), DATETIME_CASES)
3856
def test_generate_snowflake_boundary_high(dt, expected_ms):
39-
"""Boundary mode high should set lower 22 bits to max."""
4057
sf = generate_snowflake(dt, mode="boundary", high=True)
4158
assert (sf >> 22) == expected_ms
4259
assert (sf & ((1 << 22) - 1)) == (2**22 - 1)
4360

4461

4562
@pytest.mark.parametrize(("dt", "expected_ms"), DATETIME_CASES)
4663
def test_snowflake_time_roundtrip_boundary(dt, expected_ms):
47-
"""Converting boundary snowflake back to datetime yields the original dt."""
4864
sf_low = generate_snowflake(dt, mode="boundary", high=False)
4965
sf_high = generate_snowflake(dt, mode="boundary", high=True)
50-
# snowflake_time ignores low bits, so both should map to dt
5166
assert snowflake_time(sf_low) == dt
5267
assert snowflake_time(sf_high) == dt
5368

5469

5570
@pytest.mark.parametrize(("dt", "expected_ms"), DATETIME_CASES)
5671
def test_snowflake_time_roundtrip_realistic(dt, expected_ms):
57-
"""Converting realistic snowflake back to datetime yields the original dt."""
5872
sf = generate_snowflake(dt, mode="realistic")
5973
assert snowflake_time(sf) == dt
6074

6175

6276
def test_generate_snowflake_invalid_mode():
63-
"""Passing an invalid mode should raise ValueError."""
6477
with pytest.raises(ValueError, match="Invalid mode 'nope'. Must be 'realistic' or 'boundary'"):
6578
generate_snowflake(datetime.datetime.now(tz=UTC), mode="nope")

0 commit comments

Comments
 (0)