Skip to content

Commit

Permalink
refactor and added test
Browse files Browse the repository at this point in the history
- refactored the TestCollection class
- added testcases for get_total_weight
  • Loading branch information
Kaya-Sem committed Jul 16, 2024
1 parent 26af3f7 commit b91cdb0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/test_dataobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def test_item_creation(self):


class TestCollection(unittest.TestCase):
items = {
"Shelter": [Item(1, "Tent", 2500.0, "Lightweight tent", "Shelter")],
"Sleep": [Item(2, "Sleeping Bag", 1500.0, "Warm sleeping bag", "Sleep")]
}

collection = Collection(1, "Camping Gear", "Essential camping items", items)

def test_collection_creation(self):
collection = Collection(5, "Kungsleden", "Swedens King Trail", {})
Expand All @@ -24,16 +30,16 @@ def test_collection_creation(self):
self.assertEqual(collection.description, "Swedens King Trail")

def test_get_category_weights(self):
items = {
"Shelter": [Item(1, "Tent", 2500.0, "Lightweight tent", "Shelter")],
"Sleep": [Item(2, "Sleeping Bag", 1500.0, "Warm sleeping bag", "Sleep")]
}
collection = Collection(1, "Camping Gear", "Essential camping items", items)
expected_weights = {
"Shelter": 2500.0,
"Sleep": 1500.0
}
self.assertEqual(collection.get_category_weights(), expected_weights)
self.assertEqual(self.collection.get_category_weights(), expected_weights)

def test_get_total_weight(self):
collection = Collection(1, "Camping Gear", "Essential camping items", self.items)
expected_total_weight = 4000.0
self.assertEqual(collection.get_total_weight(), expected_total_weight)


class TestConnection(unittest.TestCase):
Expand Down

0 comments on commit b91cdb0

Please sign in to comment.