Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Negative Tests #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/test_ksuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,52 @@ def test_to_from_base62():
# Assert
assert ksuid == ksuid_from_base62

def test_to_from_base62_invalid_base62_string():
# Arrange
ksuid = Ksuid()
invalid_base62 = "invalid_base62_string!"

# Act & Assert
with pytest.raises(ValueError):
ksuid.from_base62(invalid_base62)

def test_to_from_base62_empty_string():
# Arrange
ksuid = Ksuid()
empty_base62 = ""

# Act & Assert
with pytest.raises(IndexError): # this looks wrong
ksuid.from_base62(empty_base62)

def test_to_from_base62_mismatched_id():
# Arrange
ksuid = Ksuid()
base62 = str("00000000000000000000000-00")

# Act & Assert
with pytest.raises(ValueError): # this looks wrong
ksuid.from_base62(base62)

def test_to_from_base62_digit_input():
# Arrange
ksuid = Ksuid()
non_string_input = "1234567890"

# Act & Assert
with pytest.raises(Exception):
ksuid.from_base62(non_string_input)

def test_to_from_base62_zero_value_ksuid():
# Arrange
zero_ksuid = Ksuid.from_base62("000000000000000000000000000")
base62 = str(zero_ksuid)

# Act
ksuid_from_base62 = zero_ksuid.from_base62(base62)

# Assert
assert zero_ksuid == ksuid_from_base62

def test_to_from_bytes():
# Arrange
Expand Down