예제 #1
0
    def test_add_multiple_items_to_box_package(self):
        height0 = 1.0
        width0 = 2.0
        depth0 = 3.0
        weight0 = 0.3

        height1 = 2.0
        width1 = 3.0
        depth1 = 4.0
        weight1 = 1.0

        package = BoxPackage()
        package.add_item(height0, width0, depth0, weight0)
        package.add_item(height1, width1, depth1, weight1)

        self.assertTrue(package.has_items())

        self.assertEqual(height0, package.get_items()[0].height)
        self.assertEqual(width0, package.get_items()[0].width)
        self.assertEqual(depth0, package.get_items()[0].depth)
        self.assertEqual(weight0, package.get_items()[0].weight)

        self.assertEqual(height1, package.get_items()[1].height)
        self.assertEqual(width1, package.get_items()[1].width)
        self.assertEqual(depth1, package.get_items()[1].depth)
        self.assertEqual(weight1, package.get_items()[1].weight)
예제 #2
0
    def test_get_weight_of_box_package(self):
        weight0 = 0.5
        weight1 = 1.5

        package = BoxPackage()
        package.add_item(1.0, 2.0, 3.0, weight0)
        package.add_item(2.0, 3.0, 5.0, weight1)

        self.assertEqual(weight0 + weight1, package.get_weight())
예제 #3
0
    def test_get_dimensions_for_single_item_box_package_with_dimensions_over_the_minimum(
            self):
        height = 15.0
        width = 20.0
        depth = 25.0

        package = BoxPackage()
        package.add_item(height, width, depth, 0.3)

        dimensions = package.get_dimensions()
        self.assertTupleEqual(dimensions, (height, width, depth))
예제 #4
0
    def test_get_dimensions_for_single_item_box_package_with_minimum_dimensions(
            self):
        height = 1.0
        width = 2.0
        depth = 3.0

        package = BoxPackage()
        package.add_item(height, width, depth, 0.3)

        dimensions = package.get_dimensions()
        self.assertTupleEqual(dimensions,
                              (BoxPackage.MIN_HEIGHT, BoxPackage.MIN_WIDTH,
                               BoxPackage.MIN_DEPTH))
예제 #5
0
    def test_add_single_item_to_box_package(self):
        height = 1.0
        width = 2.0
        depth = 3.0
        weight = 0.3

        package = BoxPackage()
        package.add_item(height, width, depth, weight)

        self.assertTrue(package.has_items())
        self.assertEqual(height, package.get_items()[0].height)
        self.assertEqual(width, package.get_items()[0].width)
        self.assertEqual(depth, package.get_items()[0].depth)
        self.assertEqual(weight, package.get_items()[0].weight)
예제 #6
0
    def test_api_format_for_valid_box_package(self):
        height = 15.0
        width = 20.0
        depth = 35.0
        weight = 1.2

        package = BoxPackage()
        package.add_item(height, width, depth, weight)
        expected = {
            'nCdFormato': Package.FORMAT_BOX,
            'nVlAltura': height,
            'nVlLargura': width,
            'nVlComprimento': depth,
            'nVlPeso': weight
        }
        self.assertDictEqual(package.api_format(), expected)
예제 #7
0
    def test_get_dimensions_for_multiple_items_box_package_with_dimensions_over_the_minimum(
            self):
        height0 = 10
        width0 = 12
        depth0 = 25
        weight0 = 0.3

        height1 = 6
        width1 = 14
        depth1 = 20
        weight1 = 1.0

        package = BoxPackage()
        package.add_item(height0, width0, depth0, weight0)
        package.add_item(height1, width1, depth1, weight1)

        dimensions = package.get_dimensions()
        self.assertTupleEqual(dimensions, (height0 + height1, width1, depth0))
예제 #8
0
    def test_get_dimensions_for_multiple_items_box_package_with_minimum_dimensions(
            self):
        height0 = 0.5
        width0 = 0.5
        depth0 = 0.5
        weight0 = 0.3

        height1 = 0.5
        width1 = 0.8
        depth1 = 0.6
        weight1 = 1.0

        package = BoxPackage()
        package.add_item(height0, width0, depth0, weight0)
        package.add_item(height1, width1, depth1, weight1)

        dimensions = package.get_dimensions()
        self.assertTupleEqual(dimensions,
                              (BoxPackage.MIN_HEIGHT, BoxPackage.MIN_WIDTH,
                               BoxPackage.MIN_DEPTH))
예제 #9
0
 def test_api_format_for_invalid_box_package(self):
     package = BoxPackage()
     package.add_item(100.0, 100.0, 100.0, 5.0)
     with self.assertRaises(Exception):
         package.api_format()
예제 #10
0
 def test_check_for_valid_box_package_with_exceeded_volume(self):
     package = BoxPackage()
     package.add_item(100.0, 100.0, 100.0, 5.0)
     self.assertFalse(package.is_valid())
예제 #11
0
 def test_check_for_valid_box_package_with_exceeded_dimensions(self):
     package = BoxPackage()
     package.add_item(BoxPackage.MAX_HEIGHT + 1.0,
                      BoxPackage.MAX_WIDTH + 1.0,
                      BoxPackage.MAX_DEPTH + 1.0, 2.0)
     self.assertFalse(package.is_valid())
예제 #12
0
 def test_check_for_valid_box_package_with_valid_dimensions(self):
     package = BoxPackage()
     package.add_item(15.0, 20.0, 35.0, 1.2)
     self.assertTrue(package.is_valid())