From eb5e366cce478a0cf034a0f0ea5e390f8c08f778 Mon Sep 17 00:00:00 2001 From: fraguada Date: Wed, 20 Nov 2024 10:31:17 +0100 Subject: [PATCH] updating tests --- tests/javascript/file3dm.BitmapTable.test.js | 33 +++++++++++++++ .../javascript/file3dm.MaterialTable.test.js | 41 +++++++++++++++++++ tests/javascript/file3dm.ObjectTable.test.js | 6 +-- tests/python/test_File3dm_BitmapTable.py | 36 ++++++++++++++++ tests/python/test_File3dm_LayerTable.py | 3 +- tests/python/test_File3dm_MaterialTable.py | 33 +++++++++++++++ tests/python/test_File3dm_ObjectTable.py | 2 - 7 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 tests/javascript/file3dm.BitmapTable.test.js create mode 100644 tests/javascript/file3dm.MaterialTable.test.js create mode 100644 tests/python/test_File3dm_BitmapTable.py create mode 100644 tests/python/test_File3dm_MaterialTable.py diff --git a/tests/javascript/file3dm.BitmapTable.test.js b/tests/javascript/file3dm.BitmapTable.test.js new file mode 100644 index 00000000..ae1cb4ba --- /dev/null +++ b/tests/javascript/file3dm.BitmapTable.test.js @@ -0,0 +1,33 @@ +const rhino3dm = require('rhino3dm') + +let rhino +beforeEach( async() => { + rhino = await rhino3dm() + }) +//TODO +// Skipping for now. +test.skip('DeleteBitmap', async () => { + + const file3dm = new rhino.File3dm() + file3dm.applicationName = 'rhino3dm.js' + file3dm.applicationDetails = 'rhino3dm-tests-bitmapTable-deleteBitmap' + file3dm.applicationUrl = 'https://rhino3d.com' + + const bm1 = new rhino.Bitmap() + const bm2 = new rhino.Bitmap() + + // .bitmaps().add() is void + model.bitmaps().add(bm1) + model.bitmaps().add(bm2) + + const qtyBitmaps1 = model.bitmaps().count + + const id1 = model.bitmaps().get(0).id + + model.bitmaps().delete(id1) + + const qtyBitmaps2 = model.bitmaps().count + + expect(qtyDims1 === 2 && qtyDims2 === 1).toBe(true) + +}) \ No newline at end of file diff --git a/tests/javascript/file3dm.MaterialTable.test.js b/tests/javascript/file3dm.MaterialTable.test.js new file mode 100644 index 00000000..92442a43 --- /dev/null +++ b/tests/javascript/file3dm.MaterialTable.test.js @@ -0,0 +1,41 @@ +const rhino3dm = require('rhino3dm') + +let rhino +beforeEach( async() => { + rhino = await rhino3dm() + }) +//TODO + +test('DeleteMaterial', async () => { + + const file3dm = new rhino.File3dm() + file3dm.applicationName = 'rhino3dm.js' + file3dm.applicationDetails = 'rhino3dm-tests-materialTable-deleteMaterial' + file3dm.applicationUrl = 'https://rhino3d.com' + + const material1 = new rhino.Material() + material1.toPhysicallyBased() + material1.physicallyBased().baseColor = { r: 1, g: 0, b: 0, a: 0 } + material1.physicallyBased().metallic = 0.7 + material1.physicallyBased().roughness = 0.5 + + const material2 = new rhino.Material() + material2.toPhysicallyBased() + material2.physicallyBased().baseColor = { r: 1, g: 0, b: 0, a: 0 } + material2.physicallyBased().metallic = 0.7 + material2.physicallyBased().roughness = 0.5 + + const index1 = model.materials().add(material1) + const index2 = model.materials().add(material2) + + const qtyMaterials1 = model.materials().count + + const id1 = model.materials().get(index1).id + + model.materials().delete(id1) + + const qtyMaterials2 = model.materials().count + + expect(qtyMaterials1 === 2 && qtyMaterials2 === 1).toBe(true) + +}) \ No newline at end of file diff --git a/tests/javascript/file3dm.ObjectTable.test.js b/tests/javascript/file3dm.ObjectTable.test.js index 4b396826..fd1e1838 100644 --- a/tests/javascript/file3dm.ObjectTable.test.js +++ b/tests/javascript/file3dm.ObjectTable.test.js @@ -41,11 +41,11 @@ test('DeleteObject', async () => { file3dm.applicationDetails = 'rhino3dm-tests-objectTable-deleteObject' file3dm.applicationUrl = 'https://rhino3d.com' - const circle1 = new rhino3dm.Circle(5); - const circle2 = new rhino3dm.Circle(50); + const circle1 = new rhino.Circle(5); + const circle2 = new rhino.Circle(50); const id1 = file3dm.objects().addCircle(circle1) - const id2 = file3dm.objects().addCircle(circle2) + file3dm.objects().addCircle(circle2) const qtyObjects = file3dm.objects().count diff --git a/tests/python/test_File3dm_BitmapTable.py b/tests/python/test_File3dm_BitmapTable.py new file mode 100644 index 00000000..b525a6ef --- /dev/null +++ b/tests/python/test_File3dm_BitmapTable.py @@ -0,0 +1,36 @@ +import rhino3dm +import unittest + +#objective: to test creating file with bitmaps +@unittest.skip("Can't seem to add to the bitmap table for now.") +class TestFile3dmBitmapTable(unittest.TestCase): + + def test_deleteBitmap(self): + file3dm = rhino3dm.File3dm() + file3dm.ApplicationName = 'python' + file3dm.ApplicationDetails = 'rhino3dm-tests-deleteBitmap' + file3dm.ApplicationUrl = 'https://rhino3d.com' + + #create bitmaps + bm1 = rhino3dm.Bitmap() + bm2 = rhino3dm.Bitmap() + + file3dm.Bitmaps.Add(bm1) + file3dm.Bitmaps.Add(bm2) + + qtyBitmaps1 = len(file3dm.Bitmaps) + + print(qtyBitmaps1) + + id1 = file3dm.Bitmaps[0].Id + + file3dm.Bitmaps.Delete(id1) + + qtyBitmaps2 = len(file3dm.Bitmaps) + + self.assertTrue(qtyBitmaps1 == 2 and qtyBitmaps2 == 1) + +if __name__ == '__main__': + print("running tests") + unittest.main() + print("tests complete") \ No newline at end of file diff --git a/tests/python/test_File3dm_LayerTable.py b/tests/python/test_File3dm_LayerTable.py index f11fb0cc..a391f0b5 100644 --- a/tests/python/test_File3dm_LayerTable.py +++ b/tests/python/test_File3dm_LayerTable.py @@ -1,7 +1,7 @@ import rhino3dm import unittest -#objective: to test creating file with layers and reasing a file with layers +#objective: to test creating file with layers and reading a file with layers class TestFile3dmLayerTable(unittest.TestCase): def test_createFileWithLayers(self): @@ -30,6 +30,7 @@ def test_createFileWithLayers(self): self.assertTrue(qtyLayers == 2 and qtyLayers2 == 2) +#objective: to test creating file with layers and deleting a layer def test_deleteLayer(self): file3dm = rhino3dm.File3dm() file3dm.ApplicationName = 'python' diff --git a/tests/python/test_File3dm_MaterialTable.py b/tests/python/test_File3dm_MaterialTable.py new file mode 100644 index 00000000..642e9227 --- /dev/null +++ b/tests/python/test_File3dm_MaterialTable.py @@ -0,0 +1,33 @@ +import rhino3dm +import unittest + +#objective: to test creating file with bitmaps +class TestFile3dmMaterialTable(unittest.TestCase): + + def test_deleteMaterial(self): + file3dm = rhino3dm.File3dm() + file3dm.ApplicationName = 'python' + file3dm.ApplicationDetails = 'rhino3dm-tests-deleteMaterial' + file3dm.ApplicationUrl = 'https://rhino3d.com' + + #create materials + mat1 = rhino3dm.Material() + mat2 = rhino3dm.Material() + + index1 = file3dm.Materials.Add(mat1) + index2 = file3dm.Materials.Add(mat2) + + qtyMaterials1 = len(file3dm.Materials) + + id1 = file3dm.Materials[index1].Id + + file3dm.Materials.Delete(id1) + + qtyMaterials2 = len(file3dm.Materials) + + self.assertTrue(qtyMaterials1 == 2 and qtyMaterials2 == 1) + +if __name__ == '__main__': + print("running tests") + unittest.main() + print("tests complete") \ No newline at end of file diff --git a/tests/python/test_File3dm_ObjectTable.py b/tests/python/test_File3dm_ObjectTable.py index 5b3ab06a..edf875e9 100644 --- a/tests/python/test_File3dm_ObjectTable.py +++ b/tests/python/test_File3dm_ObjectTable.py @@ -53,8 +53,6 @@ def test_deleteObject(self): circle = rhino3dm.Circle(5) point = rhino3dm.Point3d(0,0,0) id1 = file3dm.Objects.AddCircle(circle) - print("delete object") - print(id1) id2 = file3dm.Objects.AddPoint(rhino3dm.Point3d(0,0,0)) qtyObjects = len(file3dm.Objects)