def test_get_set_spatial_regions(self):
     dr = DescriptorRequest()
     ul = np.array([0, 0])
     lr = np.array([720, 1080])
     b = bbI(ul, lr)
     dr.spatial_regions = np.array([b])
     b_arr = dr.spatial_regions
     npt.assert_array_equal(b_arr[0].upper_left(), ul)
    def test_set_and_get_image_data(self):
        dr = DescriptorRequest()

        imc_list = [ImageContainer(Image())]
        dr.image_data = imc_list
        nt.assert_equals(len(dr.image_data), len(imc_list))
        nt.assert_equals(len(imc_list), 1)
        nt.assert_equals(dr.image_data[0].size(), imc_list[0].size())
        nt.assert_equals(imc_list[0].size(), 0)

        imc_list.append(ImageContainer(Image(720, 480)))
        dr.image_data = imc_list
        nt.assert_equals(len(dr.image_data), len(imc_list))
        nt.assert_equals(len(imc_list), 2)
        nt.assert_equals(dr.image_data[0].size(), imc_list[0].size())
        nt.assert_equals(imc_list[0].size(), 0)
        nt.assert_equals(dr.image_data[1].size(), imc_list[1].size())
        nt.assert_equals(imc_list[1].size(), 720 * 480)

        dr.image_data = []
        nt.assert_equals(len(dr.image_data), 0)
    def test_set_and_get_data_location(self):
        dr = DescriptorRequest()

        nt.assert_equals(dr.data_location, "")

        dr.data_location = "first"
        nt.assert_equals(dr.data_location, "first")

        dr.data_location = "second"
        nt.assert_equals(dr.data_location, "second")

        dr.data_location = "42"
        nt.assert_equals(dr.data_location, "42")

        dr.data_location = ""
        nt.assert_equals(dr.data_location, "")
    def test_set_and_get_id(self):
        dr = DescriptorRequest()

        # First check default
        nt.assert_equals(dr.id.value(), "")
        nt.assert_false(dr.id.is_valid())

        # Now check setting and getting a few values
        dr.id = UID("first")
        nt.assert_equals(dr.id.value(), "first")

        dr.id = UID("second")
        nt.assert_equals(dr.id.value(), "second")

        dr.id = UID("42")
        nt.assert_equals(dr.id.value(), "42")

        # Try setting back to empty
        dr.id = UID()
        nt.assert_equals(dr.id.value(), "")
    def test_set_and_get_temporal_bounds(self):
        dr = DescriptorRequest()

        # First check the defaults
        nt.assert_false(dr.temporal_lower_bound().is_valid())
        nt.assert_false(dr.temporal_upper_bound().is_valid())

        test_bounds = [
            (Timestamp(100, 1), Timestamp(100, 1)),
            (Timestamp(100, 1), Timestamp(200, 2)),
            (Timestamp(300, 5), Timestamp(400, 6)),
        ]

        for (t1, t2) in test_bounds:
            dr.set_temporal_bounds(t1, t2)
            nt.assert_equals(dr.temporal_lower_bound(), t1)
            nt.assert_equals(dr.temporal_upper_bound(), t2)

        dr.set_temporal_bounds(Timestamp(), Timestamp())
        nt.assert_false(dr.temporal_lower_bound().is_valid())
        nt.assert_false(dr.temporal_upper_bound().is_valid())
 def test_bad_set_id(self):
     dr = DescriptorRequest()
     dr.id = "string, not uid"
 def test_create(self):
     DescriptorRequest()
 def test_bad_set_data_location(self):
     dr = DescriptorRequest()
     dr.data_location = 5
 def test_bad_set_image_data(self):
     dr = DescriptorRequest()
     dr.image_data = "string, not image_data"
 def test_bad_set_spatial_regions(self):
     dr = DescriptorRequest()
     dr.spatial_regions = "string, not list"
 def test_bad_set_temporal_bounds(self):
     dr = DescriptorRequest()
     dr.set_temporal_bounds("string", "another_string")