Beispiel #1
0
 def test_error_set_point_with_wrong_axis_count(self):
     tags = ClassifiedTags.from_text("13\n1.0\n23\n2.0\n40\n0.0\n")
     point = PointAccessor(tags)
     with self.assertRaises(ValueError):
         point.dxf.flex = (3., 4., 5., 6.)
     with self.assertRaises(ValueError):
         point.dxf.flex = (3., )
Beispiel #2
0
 def test_error_set_point_with_wrong_axis_count(self):
     tags = ClassifiedTags.from_text("13\n1.0\n23\n2.0\n40\n0.0\n")
     point = PointAccessor(tags)
     with self.assertRaises(ValueError):
         point.dxf.flex = (3., 4., 5., 6.)
     with self.assertRaises(ValueError):
         point.dxf.flex = (3., )
Beispiel #3
0
 def test_getdxfattr_no_DXF_default_value_at_wrong_dxf_version(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     # just_AC1015 has a DXF default value, but the drawing has an insufficient DXF version
     with self.assertRaises(ValueError):
         point.get_dxf_attrib('just_AC1015')
     # except the USER defined default value
     self.assertEqual(17, point.get_dxf_attrib('just_AC1015', 17))
Beispiel #4
0
 def test_set_2d_point_at_existing_3d_point(self):
     tags = ClassifiedTags.from_text("13\n1.0\n23\n2.0\n33\n3.0\n")
     point = PointAccessor(tags)
     point.dxf.flex = (3., 4.)
     self.assertEqual(
         1, len(tags.noclass)
     )  # points represented by just one tag since v0.6 (code, (x, y[, z]))
     self.assertEqual((3., 4.), point.dxf.flex)
Beispiel #5
0
 def test_getdxfattr_no_DXF_default_value_at_wrong_dxf_version(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     # just_AC1015 has a DXF default value, but the drawing has an insufficient DXF version
     with self.assertRaises(ValueError):
         point.get_dxf_attrib('just_AC1015')
     # except the USER defined default value
     self.assertEqual(17, point.get_dxf_attrib('just_AC1015', 17))
Beispiel #6
0
 def test_set_point(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     point.dxf.point = (7, 8, 9)
     self.assertEqual(
         1, len(tags.noclass)
     )  # points represented by just one tag since v0.6 (code, (x, y[, z]))
     self.assertEqual((7., 8., 9.), point.dxf.point)
Beispiel #7
0
 def test_set_2d_point(self):
     point = PointAccessor(
         ClassifiedTags.from_text("11\n1.0\n21\n2.0\n40\n3.0\n"))
     point.dxf.flat = (4, 5)
     self.assertEqual(
         2, len(point.tags.noclass)
     )  # points represented by just one tag since v0.6 (code, (x, y[, z]))
     self.assertEqual((4., 5.), point.dxf.flat)
Beispiel #8
0
 def test_delete_xtype_dxfattrib(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertEqual((1.0, 2.0, 3.0), point.dxf.point)
     del point.dxf.point
     self.assertFalse(point.dxf_attrib_exists('point'))
     # low level check
     point_tags = [tag for tag in point.tags.noclass if tag.code in (10, 20, 30)]
     self.assertEqual(0, len(point_tags))
Beispiel #9
0
 def test_delete_xtype_dxfattrib(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertEqual((1.0, 2.0, 3.0), point.dxf.point)
     del point.dxf.point
     self.assertFalse(point.dxf_attrib_exists('point'))
     # low level check
     point_tags = [
         tag for tag in point.tags.noclass if tag.code in (10, 20, 30)
     ]
     self.assertEqual(0, len(point_tags))
Beispiel #10
0
 def test_get_3d_point_shift(self):
     tags = ClassifiedTags.from_text("12\n1.0\n22\n2.0\n32\n3.0\n")
     point = PointAccessor(tags)
     self.assertEqual((1., 2., 3.), point.dxf.xp)
Beispiel #11
0
 def test_delete_simple_dxfattrib(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertEqual(7, point.dxf.flags)
     del point.dxf.flags
     self.assertFalse(point.dxf_attrib_exists('flags'))
Beispiel #12
0
 def test_delete_not_supported_dxfattrib(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     with self.assertRaises(AttributeError):
         del point.dxf.mozman
Beispiel #13
0
 def test_set_not_existing_3D_point(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertFalse(point.dxf_attrib_exists('xp'))
     point.dxf.xp = (7, 8, 9)
     self.assertEqual((7, 8, 9), point.dxf.xp)
Beispiel #14
0
 def setUp(self):
     self.dxfdict = DXFDictionaryWithDefault(ClassifiedTags.from_text(DEFAULT_DICT))
Beispiel #15
0
 def test_attribute_error(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     with self.assertRaises(AttributeError):
         point.dxf.xflag
Beispiel #16
0
 def test_set_2d_point_at_existing_3d_point(self):
     tags = ClassifiedTags.from_text("13\n1.0\n23\n2.0\n33\n3.0\n")
     point = PointAccessor(tags)
     point.dxf.flex = (3., 4.)
     self.assertEqual(1, len(tags.noclass))  # points represented by just one tag since v0.6 (code, (x, y[, z]))
     self.assertEqual((3., 4.), point.dxf.flex)
Beispiel #17
0
 def test_error(self):
     tags = ClassifiedTags.from_text("12\n1.0\n22\n2.0\n32\n3.0\n")
     point = PointAccessor(tags)
     with self.assertRaises(ValueError):
         point.dxf.point
Beispiel #18
0
 def test_get_3d_point_shift(self):
     tags = ClassifiedTags.from_text("12\n1.0\n22\n2.0\n32\n3.0\n")
     point = PointAccessor(tags)
     self.assertEqual((1., 2., 3.), point.dxf.xp)
Beispiel #19
0
 def test_error_get_2d_point_for_required_3d_point(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n  0\n")
     point = PointAccessor(tags)
     with self.assertRaises(DXFStructureError):
         point.dxf.point
Beispiel #20
0
 def test_set_not_existing_flex_point_as_2D(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertFalse(point.dxf_attrib_exists('flex'))
     point.dxf.flex = (7, 8)
     self.assertEqual((7, 8), point.dxf.flex)
Beispiel #21
0
 def test_set_not_existing_3D_point_with_wrong_axis_count(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertFalse(point.dxf_attrib_exists('xp'))
     with self.assertRaises(ValueError):
         point.dxf.xp = (7, 8)
Beispiel #22
0
 def test_get_2d_point(self):
     point = PointAccessor(ClassifiedTags.from_text("11\n1.0\n21\n2.0\n40\n3.0\n"))
     self.assertEqual((1., 2.), point.dxf.flat)
Beispiel #23
0
 def test_get_2d_point(self):
     point = PointAccessor(
         ClassifiedTags.from_text("11\n1.0\n21\n2.0\n40\n3.0\n"))
     self.assertEqual((1., 2.), point.dxf.flat)
Beispiel #24
0
 def test_set_2d_point(self):
     point = PointAccessor(ClassifiedTags.from_text("11\n1.0\n21\n2.0\n40\n3.0\n"))
     point.dxf.flat = (4, 5)
     self.assertEqual(2, len(point.tags.noclass))  # points represented by just one tag since v0.6 (code, (x, y[, z]))
     self.assertEqual((4., 5.), point.dxf.flat)
Beispiel #25
0
 def test_error_get_2d_point_form_3d_point(self):
     point = PointAccessor(
         ClassifiedTags.from_text("11\n1.0\n21\n2.0\n31\n3.0\n"))
     with self.assertRaises(DXFStructureError):
         point.dxf.flat
Beispiel #26
0
 def setUp(self):
     self.dxfdict = DXFDictionary(ClassifiedTags.from_text(EMPTY_DICT))
Beispiel #27
0
 def test_set_dxfattrib_for_wrong_dxfversion_error(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     with self.assertRaises(AttributeError):
         point.dxf.just_AC1015 = 7
Beispiel #28
0
 def test_set_and_get_dxfattrib(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     point.dxf.flags = 7
     self.assertEqual(7, point.dxf.flags)
Beispiel #29
0
 def test_delete_simple_dxfattrib(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertEqual(7, point.dxf.flags)
     del point.dxf.flags
     self.assertFalse(point.dxf_attrib_exists('flags'))
Beispiel #30
0
 def test_set_and_get_dxfattrib(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     point.dxf.flags = 7
     self.assertEqual(7, point.dxf.flags)
Beispiel #31
0
 def test_delete_not_supported_dxfattrib(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     with self.assertRaises(AttributeError):
         del point.dxf.mozman
Beispiel #32
0
 def test_get_dxfattrib_for_wrong_dxfversion_without_error(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n71\n999\n")
     point = PointAccessor(tags)
     self.assertEqual(999, point.dxf.just_AC1015, "If false tags are there, don't care")
Beispiel #33
0
 def test_get_3d_point(self):
     tags = ClassifiedTags.from_text("13\n1.0\n23\n2.0\n33\n3.0\n")
     point = PointAccessor(tags)
     self.assertEqual((1., 2., 3.), point.dxf.flex)
Beispiel #34
0
 def test_set_not_existing_3D_point_with_wrong_axis_count(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertFalse(point.dxf_attrib_exists('xp'))
     with self.assertRaises(ValueError):
         point.dxf.xp = (7, 8)
Beispiel #35
0
 def test_error_get_2d_point_for_required_3d_point(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n  0\n")
     point = PointAccessor(tags)
     with self.assertRaises(DXFStructureError):
         point.dxf.point
Beispiel #36
0
 def test_set_not_existing_3D_point(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertFalse(point.dxf_attrib_exists('xp'))
     point.dxf.xp = (7, 8, 9)
     self.assertEqual((7, 8, 9), point.dxf.xp)
Beispiel #37
0
 def test_get_dxfattrib_for_wrong_dxfversion_without_error(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n71\n999\n")
     point = PointAccessor(tags)
     self.assertEqual(999, point.dxf.just_AC1015,
                      "If false tags are there, don't care")
Beispiel #38
0
 def test_set_not_existing_flex_point_as_2D(self):
     tags = ClassifiedTags.from_text("70\n7\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertFalse(point.dxf_attrib_exists('flex'))
     point.dxf.flex = (7, 8)
     self.assertEqual((7, 8), point.dxf.flex)
Beispiel #39
0
 def setUp(self):
     self.dxfdict = DXFDictionary(ClassifiedTags.from_text(EMPTY_DICT))
Beispiel #40
0
 def test_set_point(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     point.dxf.point = (7, 8, 9)
     self.assertEqual(1, len(tags.noclass))  # points represented by just one tag since v0.6 (code, (x, y[, z]))
     self.assertEqual((7., 8., 9.), point.dxf.point)
Beispiel #41
0
 def test_supports_dxfattrib(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertTrue(point.supports_dxf_attrib('xp'))
Beispiel #42
0
 def test_error(self):
     tags = ClassifiedTags.from_text("12\n1.0\n22\n2.0\n32\n3.0\n")
     point = PointAccessor(tags)
     with self.assertRaises(ValueError):
         point.dxf.point
Beispiel #43
0
 def test_supports_dxfattrib2(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertFalse(point.supports_dxf_attrib('mozman'))
     self.assertFalse(point.supports_dxf_attrib('just_AC1015'))
Beispiel #44
0
 def test_error_get_2d_point_form_3d_point(self):
     point = PointAccessor(ClassifiedTags.from_text("11\n1.0\n21\n2.0\n31\n3.0\n"))
     with self.assertRaises(DXFStructureError):
         point.dxf.flat
Beispiel #45
0
 def test_supports_dxfattrib(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertTrue(point.supports_dxf_attrib('xp'))
Beispiel #46
0
 def test_get_3d_point(self):
     tags = ClassifiedTags.from_text("13\n1.0\n23\n2.0\n33\n3.0\n")
     point = PointAccessor(tags)
     self.assertEqual((1., 2., 3.), point.dxf.flex)
Beispiel #47
0
 def test_dxfattr_exists(self):
     tags = ClassifiedTags.from_text("70\n9\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertTrue(point.dxf_attrib_exists('flags'))
Beispiel #48
0
 def test_getdxfattr_exist(self):
     tags = ClassifiedTags.from_text("70\n9\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertEqual(9, point.get_dxf_attrib('flags', 17))
Beispiel #49
0
 def setUp(self):
     self.dxfdict = DXFDictionaryWithDefault(
         ClassifiedTags.from_text(DEFAULT_DICT))
Beispiel #50
0
 def test_supports_dxfattrib2(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertFalse(point.supports_dxf_attrib('mozman'))
     self.assertFalse(point.supports_dxf_attrib('just_AC1015'))
Beispiel #51
0
 def test_dxfattr_exists(self):
     tags = ClassifiedTags.from_text("70\n9\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertTrue(point.dxf_attrib_exists('flags'))
Beispiel #52
0
 def test_getdxfattr_exist(self):
     tags = ClassifiedTags.from_text("70\n9\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertEqual(9, point.get_dxf_attrib('flags', 17))
Beispiel #53
0
 def test_dxfattr_doesnt_exist(self):
     tags = ClassifiedTags.from_text("70\n9\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertFalse(point.dxf_attrib_exists('xp'))
Beispiel #54
0
 def test_dxfattr_doesnt_exist(self):
     tags = ClassifiedTags.from_text("70\n9\n10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     self.assertFalse(point.dxf_attrib_exists('xp'))
Beispiel #55
0
 def test_attribute_error(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     with self.assertRaises(AttributeError):
         point.dxf.xflag
Beispiel #56
0
 def test_valid_dxf_attrib_names(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     # just_AC1015 - is not valid for AC1009
     self.assertEqual(['flags', 'flat', 'flex', 'point', 'xp'], sorted(point.valid_dxf_attrib_names()))
Beispiel #57
0
 def test_valid_dxf_attrib_names(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     # just_AC1015 - is not valid for AC1009
     self.assertEqual(['flags', 'flat', 'flex', 'point', 'xp'],
                      sorted(point.valid_dxf_attrib_names()))
Beispiel #58
0
 def test_set_dxfattrib_for_wrong_dxfversion_error(self):
     tags = ClassifiedTags.from_text("10\n1.0\n20\n2.0\n30\n3.0\n")
     point = PointAccessor(tags)
     with self.assertRaises(AttributeError):
         point.dxf.just_AC1015 = 7
Beispiel #59
0
 def setUp(self):
     self.xrecord = XRecord(ClassifiedTags.from_text(XRECORD1))