Skip to content

Commit

Permalink
edit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
samirg1 committed Sep 28, 2023
1 parent 91b031c commit cba88e9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
12 changes: 7 additions & 5 deletions testing/design/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@


def test_item_creation_and_properties():
item = Item(number="123", description="Test Item", model="Model123", manufacturer="Test Manufacturer", serial="ABC456")
item = Item("123", "Test Item", "Model123", "Test Manufacturer", "ABC456", "RM1", "2019")

assert item.number == "123"
assert item.description == "Test Item"
assert item.model == "Model123"
assert item.manufacturer == "Test Manufacturer"
assert item.serial == "ABC456"
assert item.room == "RM1"
assert item.last_update == "2019"


def test_item_string_representation():
item = Item(number="789", description="Another Item", model="Model789", manufacturer="Another Manufacturer", serial="DEF789")
item = Item("789", "Another Item", "Model789", "Another Manufacturer", "DEF789", "RM1", "2019")

assert str(item) == "789 - Another Item"


def test_item_hashing_and_eq():
item1 = Item("111", "Item A", "ModelA", "ManufacturerA", "AAA111")
item2 = Item("222", "Item B", "ModelB", "ManufacturerB", "BBB222")
item3 = Item("111", "Item C", "ModelC", "ManufacturerC", "CCC333")
item1 = Item("111", "Item A", "ModelA", "ManufacturerA", "AAA111", "RM1", "2019")
item2 = Item("222", "Item B", "ModelB", "ManufacturerB", "BBB222", "RM1", "2019")
item3 = Item("111", "Item C", "ModelC", "ManufacturerC", "CCC333", "RM1", "2019")

assert len({item1, item2}) == 2
assert len({item1, item3}) == 1
Expand Down
30 changes: 15 additions & 15 deletions testing/design/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def test_job_creation_and_properties():
job = Job("CAMPEYN - ABLE VICTORIA", "CampusA", "DepartmentY")
job = Job("CAMPEYN - ABLE VICTORIA", "CampusA", "DepartmentY", "123")

assert job.company == "ABLE"
assert job.campus == "CampusA"
Expand All @@ -17,10 +17,10 @@ def test_job_creation_and_properties():


def test_job_add_test():
job = Job("CompanyX", "CampusA", "DepartmentY")
job = Job("CompanyX", "CampusA", "DepartmentY", "123")

test1 = Test(Item("001", "Test Item 1", "ModelX", "ManufacturerX", "XYZ001"))
test2 = Test(Item("002", "Test Item 2", "ModelY", "ManufacturerY", "XYZ002"))
test1 = Test(Item("001", "Test Item 1", "ModelX", "ManufacturerX", "XYZ001", "RM1", "2019"))
test2 = Test(Item("002", "Test Item 2", "ModelY", "ManufacturerY", "XYZ002", "RM1", "2019"))

custom1 = Script("Custom1", "Custom Script", (), exact_matches=["Test Item 1"])
SCRIPTS["Custom1"] = custom1
Expand All @@ -42,9 +42,9 @@ def test_job_add_test():
def test_job_remove_test() -> None:
custom1 = Script("Custom1", "Custom Script", (), exact_matches=["Test Item 1"])
SCRIPTS["Custom1"] = custom1
test1 = Test(Item("001", "Test Item 1", "ModelX", "ManufacturerX", "XYZ001"))
test1 = Test(Item("001", "Test Item 1", "ModelX", "ManufacturerX", "XYZ001", "RM1", "2019"))
test1.script = test1.determine_script()
job = Job("CompanyX", "CampusA", "DepartmentY")
job = Job("CompanyX", "CampusA", "DepartmentY", "123")
job.add_test(test1)
job.remove_test(test1)

Expand All @@ -55,19 +55,19 @@ def test_job_remove_test() -> None:


def test_job_string_representation():
job1 = Job("CAMPEYN - YOORALLA", "CampusA", "DepartmentY")
job2 = Job("BENETAS - ST PAULS", "CampusA", "DepartmentY")
job3 = Job("JEWISH ST KILDA", "CampusA", "DepartmentY")
job1 = Job("CAMPEYN - YOORALLA", "CampusA", "DepartmentY", "123")
job2 = Job("BENETAS - ST PAULS", "CampusA", "DepartmentY", "123")
job3 = Job("JEWISH ST KILDA", "CampusA", "DepartmentY", "123")

assert str(job1) == "CampusA\nCAMPEYN\nDepartmentY"
assert str(job2) == "CampusA\nBENETAS\nDepartmentY"
assert str(job3) == "CampusA\nJEWISH CARE\nDepartmentY"
assert str(job1) == "CampusA\nCAMPEYN\n123"
assert str(job2) == "CampusA\nBENETAS\n123"
assert str(job3) == "CampusA\nJEWISH CARE\n123"


def test_job_hashing_and_eq():
job1 = Job("CompanyX", "CampusA", "DepartmentY")
job2 = Job("CompanyY", "CampusB", "DepartmentZ")
job3 = Job("CompanyZ", "CampusA", "DepartmentZ")
job1 = Job("CompanyX", "CampusA", "DepartmentY", "123")
job2 = Job("CompanyY", "CampusB", "DepartmentZ", "123")
job3 = Job("CompanyZ", "CampusA", "DepartmentZ", "123")
assert len({job1, job2}) == 2
assert len({job1, job3}) == 1
assert hash(job1) != hash(job2)
Expand Down
10 changes: 5 additions & 5 deletions testing/design/test_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def test_test_creation_and_properties():
item = Item("001", "Test Item", "ModelX", "ManufacturerX", "XYZ001")
item = Item("001", "Test Item", "ModelX", "ManufacturerX", "XYZ001", "RM1", "2019")
test = Test(item)

with pytest.raises(ScriptError):
Expand All @@ -25,7 +25,7 @@ def test_test_creation_and_properties():


def test_test_determine_script():
item = Item("001", "Test Item", "ModelX", "ManufacturerX", "XYZ001")
item = Item("001", "Test Item", "ModelX", "ManufacturerX", "XYZ001", "RM1", "2019")
test = Test(item)

# Adding a custom script for testing
Expand All @@ -40,7 +40,7 @@ def test_test_determine_script():


def test_test_add_testjob():
item = Item("001", "SLING 123", "ModelX", "ManufacturerX", "XYZ001")
item = Item("001", "SLING 123", "ModelX", "ManufacturerX", "XYZ001", "RM1", "2019")
test = Test(item)

test.script = test.determine_script()
Expand All @@ -54,7 +54,7 @@ def test_test_add_testjob():


def test_test_complete_and_full_info():
item = Item("001", "Test Item", "ModelX", "ManufacturerX", "XYZ001")
item = Item("001", "Test Item", "ModelX", "ManufacturerX", "XYZ001", "RM1", "2019")
test = Test(item)

custom = Script("CustomScript", "Custom Script", (), exact_matches=["Test Item"])
Expand All @@ -74,7 +74,7 @@ def test_test_complete_and_full_info():


def test_test_item_model_property():
item = Item("001", "Test Item", "ModelX", "ManufacturerX", "XYZ001")
item = Item("001", "Test Item", "ModelX", "ManufacturerX", "XYZ001", "RM1", "2019")
test = Test(item)
test.script = Script("CustomScript", "Custom Script")

Expand Down
10 changes: 5 additions & 5 deletions testing/design/test_test_job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
def test_test_job_manager_multiple_testjobs():
manager = TestJobManager()

item1 = Item("001", "Test Item 1", "ModelX", "ManufacturerX", "XYZ001")
job1 = Job("Company", "Campus", "Department")
item1 = Item("001", "Test Item 1", "ModelX", "ManufacturerX", "XYZ001", "R1", "2019")
job1 = Job("Company", "Campus", "Department", "123")
testjob1 = TestJob("Quality Control", "John Doe", "Performing testing on batch 1")
testjob2 = TestJob("Quality Control", "Jane Smith", "Inspection for defects")

Expand All @@ -31,9 +31,9 @@ def test_test_job_manager_multiple_testjobs():
def test_test_job_manager_multiple_items():
manager = TestJobManager()

item1 = Item("001", "Test Item 1", "ModelX", "ManufacturerX", "XYZ001")
item2 = Item("002", "Test Item 2", "ModelY", "ManufacturerY", "XYZ002")
job1 = Job("Company", "Campus", "Department")
item1 = Item("001", "Test Item 1", "ModelX", "ManufacturerX", "XYZ001", "RM1", "2019")
item2 = Item("002", "Test Item 2", "ModelY", "ManufacturerY", "XYZ002", "RM1", "2019")
job1 = Job("Company", "Campus", "Department", "123")
testjob1 = TestJob("Quality Control", "John Doe", "Performing testing on batch 1")

manager.add_testjob(item1, job1, testjob1)
Expand Down
4 changes: 2 additions & 2 deletions testing/test_db_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_get_job(job_number: str, mock_sql_job: sql_job) -> None:
assert job.department == "dept"
assert job.number == "number"
assert job.company == "company"
assert mock_sql_job.called_with[0].endswith(job_number)
assert job_number in mock_sql_job.called_with[0]
assert mock_sql_job.close_called


Expand All @@ -89,5 +89,5 @@ def test_get_item(mock_sql_item: sql_job) -> None:
assert item.model == "model"
assert item.serial == "serial"
assert item.room == "room"
assert mock_sql_item.called_with[0].endswith("123456")
assert "123456" in mock_sql_item.called_with[0]
assert mock_sql_item.close_called

0 comments on commit cba88e9

Please sign in to comment.