Commit 86cb5dc8 authored by M. Huang's avatar M. Huang
Browse files

add test case

parent 2350ec6a
......@@ -50,7 +50,7 @@ class BaseProduct( AbstractComposite, Copyable, Serializable, EventSender):
BaseProduct class (level ALL) schema 1.3 inheriting [None].
Automatically generated from fdi/dataset/resources/BaseProduct.yml on 2020-12-16 18:54:56.806326.
Automatically generated from fdi/dataset/resources/BaseProduct.yml on 2020-12-17 01:29:13.678353.
Description:
FDI base class
......@@ -81,9 +81,8 @@ FDI base class
# list of local variables.
metasToBeInstalled = copy.copy(locals())
metasToBeInstalled.pop('self')
metasToBeInstalled.pop('__class__')
metasToBeInstalled.pop('kwds')
for x in ('self', '__class__', 'kwds'):
metasToBeInstalled.pop(x)
global ProductInfo
self.pInfo = ProductInfo
......@@ -319,7 +318,7 @@ def value2parameter(name, value, met):
valid=gs,
typecode=cs
)
elif DataTypes[im['data_type']] in ['int', 'float', 'vector', 'quaternion']:
elif DataTypes[im['data_type']] in ['int', 'float', 'Vector', 'Quaternion']:
us = im['unit'] if 'unit' in im else ''
cs = im['typecode'] if 'typecode' in im else None
ret = NumericParameter(value=value,
......
......@@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
class Product(BaseProduct):
""" Product class (level ALL) schema 1.3 inheriting ['BaseProduct'].
Automatically generated from fdi/dataset/resources/Product.yml on 2020-12-16 18:54:56.841149.
Automatically generated from fdi/dataset/resources/Product.yml on 2020-12-17 01:29:13.700199.
Description:
Project level product
......@@ -56,9 +56,8 @@ Project level product
# list of local variables.
metasToBeInstalled = copy.copy(locals())
metasToBeInstalled.pop('self')
metasToBeInstalled.pop('__class__')
metasToBeInstalled.pop('kwds')
for x in ('self', '__class__', 'kwds'):
metasToBeInstalled.pop(x)
global ProductInfo
self.pInfo = ProductInfo
......
......@@ -69,9 +69,8 @@ $INITARGS
# list of local variables.
metasToBeInstalled = copy.copy(locals())
metasToBeInstalled.pop('self')
metasToBeInstalled.pop('__class__')
metasToBeInstalled.pop('kwds')
for x in ('self', '__class__', 'kwds'):
metasToBeInstalled.pop(x)
global ProductInfo
self.pInfo = ProductInfo
......@@ -266,7 +265,7 @@ def value2parameter(name, value, met):
valid=gs,
typecode=cs
)
elif DataTypes[im['data_type']] in ['int', 'float', 'vector', 'quaternion']:
elif DataTypes[im['data_type']] in ['int', 'float', 'Vector', 'Quaternion']:
us = im['unit'] if 'unit' in im else ''
cs = im['typecode'] if 'typecode' in im else None
ret = NumericParameter(value=value,
......
......@@ -38,9 +38,8 @@ $INITARGS
# list of local variables.
metasToBeInstalled = copy.copy(locals())
metasToBeInstalled.pop('self')
metasToBeInstalled.pop('__class__')
metasToBeInstalled.pop('kwds')
for x in ('self', '__class__', 'kwds'):
metasToBeInstalled.pop(x)
global ProductInfo
self.pInfo = ProductInfo
......
......@@ -1839,7 +1839,7 @@ def check_Product(AProd):
# print(x.meta.toString())
# attribute added by Product
if AProd.__name__ == x.pInfo['name']:
assert x.meta['type'].value == x.__class__.__qualname__
assert x.meta['type'].value == x.__class__.__name__
assert x.meta['description'].value == "This is my product example"
assert x.meta['instrument'].value == "MyFavourite"
assert x.modelName == "Flight"
......@@ -1891,14 +1891,49 @@ def test_Product():
def test_SubProduct():
# sub-classing
class SP(BaseProduct):
def __init__(self, **kwds):
super().__init__(**kwds)
# 'version' of subclass is int, not string
from fdi.dataset.product import ProductInfo as PPI
class SP(Product):
def __init__(self,
description='UNKNOWN',
typ_='SP',
creator='UNKNOWN',
version=9,
creationDate=FineTime(0),
rootCause='UNKNOWN',
startDate=FineTime(0),
endDate=FineTime(0),
instrument='UNKNOWN',
modelName='UNKNOWN',
mission='_AGS',
**kwds):
metasToBeInstalled = copy.copy(locals())
for x in ('self', '__class__', 'kwds'):
metasToBeInstalled.pop(x)
sp = {}
sp.update(PPI)
sp['name'] = self.__class__.__name__
sp['metadata']['version']['data_type'] = 'integer'
sp['metadata']['version']['default'] = 9
sp['metadata']['type']['default'] = sp['name']
self.pInfo = sp
super().__init__(metasToBeInstalled=metasToBeInstalled, **kwds)
super().installMetas(mtbi=metasToBeInstalled, prodInfo=self.pInfo)
@property
def version(self): pass
@version.setter
def version(self, p): pass
y = SP()
# register it in Classes.mapping so deserializer knows how to instanciate.
Classes.mapping.update({'SP': SP})
check_Product(SP)
from fdi.pal.context import MapContext
class SSP(SP, MapContext):
......@@ -1911,11 +1946,6 @@ def test_SubProduct():
x.rr = 'r'
assert x.rr == 'r'
# register it in Classes.mapping so deserializer knows how to instanciate.
#Classes.mapping.update({'SP': SP})
# check_Product(SP)
def est_yaml2python():
import pkg_resources
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment