Skip to content

Commit

Permalink
Merge pull request #5 from VHDL/dev
Browse files Browse the repository at this point in the history
Improved unittests and coverage.
  • Loading branch information
Paebbels authored Dec 28, 2020
2 parents 79d3aa7 + 5e5ca94 commit e7b3aea
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
python setup.py bdist_wheel
- name: Release Python package to PyPI
if: startsWith(github.ref, 'refs/tags')
# if: startsWith(github.ref, 'refs/tags')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
Expand Down
8 changes: 7 additions & 1 deletion pyVHDLModel/VHDLModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,25 @@ def Documents(self) -> List['Document']:

@export
class Library(ModelEntity):
_name: str #: Library name
_contexts: List['Context'] #: List of all contexts defined in a library.
_configurations: List['Configuration'] #: List of all configurations defined in a library.
_entities: List['Entity'] #: List of all entities defined in a library.
_packages: List['Package'] #: List of all packages defined in a library.

def __init__(self):
def __init__(self, name: str):
super().__init__()

self._name = name
self._contexts = []
self._configurations = []
self._entities = []
self._packages = []

@property
def Name(self) -> str:
return self._name

@property
def Contexts(self) -> List['Context']:
return self._contexts
Expand Down
33 changes: 32 additions & 1 deletion tests/unit/Instantiate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,67 +20,98 @@ def test_Design(self):
self.assertTrue(len(design.Libraries) == 0)

def test_Library(self):
library = Library()
library = Library("lib_1")

self.assertIsNotNone(library)
self.assertTrue(library.Name == "lib_1")
self.assertTrue(len(library.Contexts) == 0)
self.assertTrue(len(library.Entities) == 0)
self.assertTrue(len(library.Packages) == 0)
self.assertTrue(len(library.Configurations) == 0)

def test_Document(self):
path = Path("tests.vhdl")
document = Document(path)

self.assertIsNotNone(document)
self.assertTrue(document.Path == path)
self.assertTrue(len(document.Entities) == 0)
self.assertTrue(len(document.Architectures) == 0)
self.assertTrue(len(document.Packages) == 0)
self.assertTrue(len(document.PackageBodies) == 0)
self.assertTrue(len(document.Contexts) == 0)
self.assertTrue(len(document.Configurations) == 0)

def test_Entity(self):
entity = Entity("entity_1")

self.assertIsNotNone(entity)
self.assertTrue(entity.Name == "entity_1")
self.assertTrue(len(entity.GenericItems) == 0)
self.assertTrue(len(entity.PortItems) == 0)
self.assertTrue(len(entity.DeclaredItems) == 0)
self.assertTrue(len(entity.BodyItems) == 0)

def test_Architecture(self):
architecture = Architecture("arch_1")

self.assertIsNotNone(architecture)
self.assertTrue(architecture.Name == "arch_1")
self.assertTrue(len(architecture.DeclaredItems) == 0)
self.assertTrue(len(architecture.BodyItems) == 0)

def test_Package(self):
package = Package("pack_1")

self.assertIsNotNone(package)
self.assertTrue(package.Name == "pack_1")
self.assertTrue(len(package.DeclaredItems) == 0)

def test_PackageBody(self):
packageBody = PackageBody("pack_1")

self.assertIsNotNone(packageBody)
self.assertTrue(packageBody.Name == "pack_1")
self.assertTrue(len(packageBody.DeclaredItems) == 0)

def test_Context(self):
context = Context("ctx_1")

self.assertIsNotNone(context)
self.assertTrue(context.Name == "ctx_1")

def test_Configuration(self):
configuration = Configuration("conf_1")

self.assertIsNotNone(configuration)
self.assertTrue(configuration.Name == "conf_1")

def test_SubType(self):
subtype = SubType("bit")

self.assertIsNotNone(subtype)
self.assertTrue(subtype.Name == "bit")

def test_Integer(self):
integer = IntegerType("integer")

self.assertIsNotNone(integer)
self.assertTrue(integer.Name == "integer")

def test_Real(self):
real = RealType("real")

self.assertIsNotNone(real)
self.assertTrue(real.Name == "real")

def test_Array(self):
array = ArrayType("bit_vector")

self.assertIsNotNone(array)
self.assertTrue(array.Name == "bit_vector")

def test_Record(self):
record = RecordType("range_record")

self.assertIsNotNone(record)
self.assertTrue(record.Name == "range_record")

0 comments on commit e7b3aea

Please sign in to comment.