Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.0
- uses: pre-commit/action@v3.0.1
16 changes: 11 additions & 5 deletions tests/iscsi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,32 @@ def test_url_parse(self):
def test_set_context_params(self):
context = iscsi.Context("foobar")
context.set_targetname("my-target")
context.set_header_digest(iscsi.ISCSI_HEADER_DIGEST_NONE)
context.set_header_digest(iscsi.iscsi_header_digest.ISCSI_HEADER_DIGEST_NONE)

def test_command(self):
context = iscsi.Context("foobar")
task = iscsi.Task(b"\x12\x00\x00\x00\x60\x00", iscsi.SCSI_XFER_READ, 96)
task = iscsi.Task(
b"\x12\x00\x00\x00\x60\x00", iscsi.scsi_xfer_dir.SCSI_XFER_READ, 96
)
data_in = bytearray(96)
context.command(0, task, None, data_in)


class TaskTest(unittest.TestCase):
def test_basic(self):
task = iscsi.Task(b"\x12\x00\x00\x00\x60\x00", iscsi.SCSI_XFER_READ, 96)
task = iscsi.Task(
b"\x12\x00\x00\x00\x60\x00", iscsi.scsi_xfer_dir.SCSI_XFER_READ, 96
)
self.assertIsNotNone(task)

def test_bytearray(self):
task = iscsi.Task(
bytearray(b"\x12\x00\x00\x00\x60\x00"), iscsi.SCSI_XFER_READ, 96
bytearray(b"\x12\x00\x00\x00\x60\x00"),
iscsi.scsi_xfer_dir.SCSI_XFER_READ,
96,
)
self.assertIsNotNone(task)

def test_empty_cdb(self):
with self.assertRaises(ValueError):
iscsi.Task(None, iscsi.SCSI_XFER_READ, 96)
iscsi.Task(None, iscsi.scsi_xfer_dir.SCSI_XFER_READ, 96)