Skip to content

Commit

Permalink
updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Nov 20, 2024
1 parent 87e08e2 commit eb5e366
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 6 deletions.
33 changes: 33 additions & 0 deletions tests/javascript/file3dm.BitmapTable.test.js
Original file line number Diff line number Diff line change
@@ -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)

})
41 changes: 41 additions & 0 deletions tests/javascript/file3dm.MaterialTable.test.js
Original file line number Diff line number Diff line change
@@ -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)

})
6 changes: 3 additions & 3 deletions tests/javascript/file3dm.ObjectTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 36 additions & 0 deletions tests/python/test_File3dm_BitmapTable.py
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 2 additions & 1 deletion tests/python/test_File3dm_LayerTable.py
Original file line number Diff line number Diff line change
@@ -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):

Expand Down Expand Up @@ -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'
Expand Down
33 changes: 33 additions & 0 deletions tests/python/test_File3dm_MaterialTable.py
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 0 additions & 2 deletions tests/python/test_File3dm_ObjectTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit eb5e366

Please sign in to comment.