本文整理汇总了Python中coloredcoinlib.ColorSet.get_data方法的典型用法代码示例。如果您正苦于以下问题:Python ColorSet.get_data方法的具体用法?Python ColorSet.get_data怎么用?Python ColorSet.get_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coloredcoinlib.ColorSet
的用法示例。
在下文中一共展示了ColorSet.get_data方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestAddress
# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import get_data [as 别名]
class TestAddress(unittest.TestCase):
def setUp(self):
self.colormap = MockColorMap()
d = self.colormap.d
self.colorset0 = ColorSet(self.colormap, [d[0]])
self.colorset1 = ColorSet(self.colormap, [d[1]])
self.main_p = '5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF'
self.main = LooseAddressRecord(address_data=self.main_p,
color_set=self.colorset0,
testnet=False)
self.test_p = '91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgyUY4Gk1'
self.test = LooseAddressRecord(address_data=self.test_p,
color_set=self.colorset1,
testnet=True)
def test_init(self):
self.assertEqual(self.main.get_address(),
'1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj')
self.assertEqual(self.test.get_address(),
'mo3oihY41iwPco1GKwehHPHmxMT4Ld5W3q')
self.assertRaises(EncodingError, LooseAddressRecord,
address_data=self.main_p[:-2] + '88')
self.assertRaises(EncodingError, LooseAddressRecord,
address_data=self.test_p[:-2] + '88',
testnet=True)
self.assertRaises(InvalidAddressError, LooseAddressRecord,
address_data=self.main_p, testnet=True)
self.assertRaises(InvalidAddressError, LooseAddressRecord,
address_data=self.test_p, testnet=False)
def test_get_color_set(self):
self.assertEqual(self.main.get_color_set().__repr__(),
self.colorset0.__repr__())
def test_get_color_address(self):
self.assertEqual(self.main.get_color_address(),
'1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj')
self.assertEqual(self.test.get_color_address(),
'[email protected]')
def test_get_data(self):
self.assertEqual(self.main.get_data()['color_set'],
self.colorset0.get_data())
self.assertEqual(self.main.get_data()['address_data'],
self.main_p)
self.assertEqual(self.test.get_data()['color_set'],
self.colorset1.get_data())
self.assertEqual(self.test.get_data()['address_data'],
self.test_p)
示例2: AssetDefinition
# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import get_data [as 别名]
class AssetDefinition(object):
"""Stores the definition of a particular asset, including its color set,
it's name (moniker), and the wallet model that represents it.
"""
def __init__(self, colormap, params):
"""Create an Asset for a color map <colormap> and configuration
<params>. Note params has the color definitions used for this
Asset.
"""
self.monikers = params.get('monikers', [])
self.color_set = ColorSet(colormap, params.get('color_set'))
self.unit = int(params.get('unit', 1))
def __repr__(self):
return "%s: %s" % (self.monikers, self.color_set)
def get_monikers(self):
"""Returns the list of monikers for this asset.
"""
return self.monikers
def get_color_set(self):
"""Returns the list of colors for this asset.
"""
return self.color_set
def get_colorvalue(self, utxo):
""" return colorvalue for a given utxo"""
if self.color_set.uncolored_only():
return utxo.value
else:
if utxo.colorvalues:
for cv in utxo.colorvalues:
if cv[0] in self.color_set.color_id_set:
return cv[1]
raise Exception("cannot get colorvalue for UTXO: "
"no colorvalues available")
def parse_value(self, portion):
"""Returns actual number of Satoshis for this Asset
given the <portion> of the asset.
"""
return int(float(portion) * self.unit)
def format_value(self, atoms):
"""Returns a string representation of the portion of the asset.
can involve rounding. doesn't display insignificant zeros
"""
return '{0:g}'.format(atoms / float(self.unit))
def get_data(self):
"""Returns a JSON-compatible object that represents this Asset
"""
return {
"monikers": self.monikers,
"color_set": self.color_set.get_data(),
"unit": self.unit
}
示例3: TestAssetDefinition
# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import get_data [as 别名]
class TestAssetDefinition(unittest.TestCase):
def setUp(self):
self.colormap = MockColorMap()
d = self.colormap.d
self.colorset0 = ColorSet(self.colormap, [''])
self.colorset1 = ColorSet(self.colormap, [d[1], d[2]])
self.colorset2 = ColorSet(self.colormap, [d[3]])
self.def0 = {'monikers': ['bitcoin'],
'color_set': self.colorset0.get_data(),
'unit':100000000}
self.def1 = {'monikers': ['test1'],
'color_set': self.colorset1.get_data(),
'unit':10}
self.def2 = {'monikers': ['test2','test2alt'],
'color_set': self.colorset2.get_data(),
'unit':1}
self.asset0 = AssetDefinition(self.colormap, self.def0)
self.asset1 = AssetDefinition(self.colormap, self.def1)
self.asset2 = AssetDefinition(self.colormap, self.def2)
self.assetvalue0 = AdditiveAssetValue(asset=self.asset0, value=5)
self.assetvalue1 = AdditiveAssetValue(asset=self.asset0, value=6)
self.assetvalue2 = AdditiveAssetValue(asset=self.asset1, value=7)
self.assettarget0 = AssetTarget('address0', self.assetvalue0)
self.assettarget1 = AssetTarget('address1', self.assetvalue1)
self.assettarget2 = AssetTarget('address2', self.assetvalue2)
config = {'asset_definitions': [self.def1, self.def2]}
self.adm = AssetDefinitionManager(self.colormap, config)
def test_repr(self):
self.assertEquals(self.asset0.__repr__(), "['bitcoin']: ['']")
self.assertEquals(
self.asset1.__repr__(),
"['test1']: ['obc:color_desc_1:0:0', 'obc:color_desc_2:0:1']")
self.assertEquals(self.asset2.__repr__(),
"['test2', 'test2alt']: ['obc:color_desc_3:0:1']")
def test_get_monikers(self):
self.assertEquals(self.asset0.get_monikers(), ['bitcoin'])
self.assertEquals(self.asset1.get_monikers(), ['test1'])
self.assertEquals(self.asset2.get_monikers(), ['test2', 'test2alt'])
def test_get_color_set(self):
self.assertTrue(self.asset0.get_color_set().equals(self.colorset0))
self.assertTrue(self.asset1.get_color_set().equals(self.colorset1))
self.assertTrue(self.asset2.get_color_set().equals(self.colorset2))
def test_get_colorvalue(self):
g = {'txhash':'blah', 'height':1, 'outindex':0}
cid0 = list(self.colorset0.color_id_set)[0]
cdef0 = OBColorDefinition(cid0, g)
cid1 = list(self.colorset1.color_id_set)[0]
cdef1 = OBColorDefinition(cid1, g)
cid2 = list(self.colorset2.color_id_set)[0]
cdef2 = OBColorDefinition(cid2, g)
cv0 = SimpleColorValue(colordef=cdef0, value=1)
cv1 = SimpleColorValue(colordef=cdef1, value=2)
cv2 = SimpleColorValue(colordef=cdef2, value=3)
utxo = MockUTXO([cv0, cv1, cv2])
self.assertEquals(self.asset0.get_colorvalue(utxo), cv0)
self.assertEquals(self.asset1.get_colorvalue(utxo), cv1)
self.assertEquals(self.asset2.get_colorvalue(utxo), cv2)
utxo = MockUTXO([cv0, cv2])
self.assertRaises(Exception, self.asset1.get_colorvalue, utxo)
def test_parse_value(self):
self.assertEquals(self.asset0.parse_value(1.25), 125000000)
self.assertEquals(self.asset1.parse_value(2), 20)
self.assertEquals(self.asset2.parse_value(5), 5)
def test_format_value(self):
self.assertEquals(self.asset0.format_value(10000),'0.0001')
self.assertEquals(self.asset1.format_value(2),'0.2')
self.assertEquals(self.asset2.format_value(5),'5')
def test_get_data(self):
self.assertEquals(self.asset0.get_data(), self.def0)
self.assertEquals(self.asset1.get_data(), self.def1)
self.assertEquals(self.asset2.get_data(), self.def2)
def test_register_asset_definition(self):
self.assertRaises(Exception, self.adm.register_asset_definition,
self.asset1)
def test_add_asset_definition(self):
colorset3 = ColorSet(self.colormap, [self.colormap.d[4]])
def4 = {'monikers': ['test3'], 'color_set': colorset3.get_data()}
self.adm.add_asset_definition(def4)
self.assertTrue(self.adm.get_asset_by_moniker('test3').get_color_set()
.equals(colorset3))
def test_all_assets(self):
reprs = [asset.__repr__() for asset in self.adm.get_all_assets()]
self.assertTrue(self.asset0.__repr__() in reprs)
#.........这里部分代码省略.........
示例4: test_add_asset_definition
# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import get_data [as 别名]
def test_add_asset_definition(self):
colorset3 = ColorSet(self.colormap, [self.colormap.d[4]])
def4 = {'monikers': ['test3'], 'color_set': colorset3.get_data()}
self.adm.add_asset_definition(def4)
self.assertTrue(self.adm.get_asset_by_moniker('test3').get_color_set()
.equals(colorset3))
示例5: TestAssetDefinition
# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import get_data [as 别名]
class TestAssetDefinition(unittest.TestCase):
def setUp(self):
self.colormap = MockColorMap()
d = self.colormap.d
self.colorset0 = ColorSet(self.colormap, [d[0]])
self.colorset1 = ColorSet(self.colormap, [d[1], d[2]])
self.colorset2 = ColorSet(self.colormap, [d[3]])
self.def0 = {'monikers': ['bitcoin'],
'color_set': self.colorset0.get_data(),
'unit':100000000}
self.def1 = {'monikers': ['test1'],
'color_set': self.colorset1.get_data(),
'unit':10}
self.def2 = {'monikers': ['test2','test2alt'],
'color_set': self.colorset2.get_data(),
'unit':1}
self.asset0 = AssetDefinition(self.colormap, self.def0)
self.asset1 = AssetDefinition(self.colormap, self.def1)
self.asset2 = AssetDefinition(self.colormap, self.def2)
config = {'asset_definitions': [self.def1, self.def2]}
self.adm = AssetDefinitionManager(self.colormap, config)
def test_repr(self):
self.assertEquals(self.asset0.__repr__(), "['bitcoin']: ['']")
self.assertEquals(
self.asset1.__repr__(),
"['test1']: ['obc:color_desc_1:0:0', 'obc:color_desc_2:0:1']")
self.assertEquals(self.asset2.__repr__(),
"['test2', 'test2alt']: ['obc:color_desc_3:0:1']")
def test_get_monikers(self):
self.assertEquals(self.asset0.get_monikers(), ['bitcoin'])
self.assertEquals(self.asset1.get_monikers(), ['test1'])
self.assertEquals(self.asset2.get_monikers(), ['test2', 'test2alt'])
def test_get_color_set(self):
self.assertTrue(self.asset0.get_color_set().equals(self.colorset0))
self.assertTrue(self.asset1.get_color_set().equals(self.colorset1))
self.assertTrue(self.asset2.get_color_set().equals(self.colorset2))
def test_get_colorvalue(self):
utxo = MockUTXO(5,[[1,2],[2,3],[3,4]])
self.assertEquals(self.asset0.get_colorvalue(utxo), 5)
self.assertEquals(self.asset1.get_colorvalue(utxo), 2)
self.assertEquals(self.asset2.get_colorvalue(utxo), 4)
utxo = MockUTXO(5,[[5,2],[6,3],[3,4]])
self.assertRaises(Exception, self.asset1.get_colorvalue, utxo)
def test_parse_value(self):
self.assertEquals(self.asset0.parse_value(1.25), 125000000)
self.assertEquals(self.asset1.parse_value(2), 20)
self.assertEquals(self.asset2.parse_value(5), 5)
def test_format_value(self):
self.assertEquals(self.asset0.format_value(10000),'0.0001')
self.assertEquals(self.asset1.format_value(2),'0.2')
self.assertEquals(self.asset2.format_value(5),'5')
def test_get_data(self):
self.assertEquals(self.asset0.get_data(), self.def0)
self.assertEquals(self.asset1.get_data(), self.def1)
self.assertEquals(self.asset2.get_data(), self.def2)
def test_register_asset_definition(self):
self.assertRaises(Exception, self.adm.register_asset_definition,
self.asset1)
def test_add_asset_definition(self):
colorset3 = ColorSet(self.colormap, [self.colormap.d[4]])
def4 = {'monikers': ['test3'], 'color_set': colorset3.get_data()}
self.adm.add_asset_definition(def4)
self.assertTrue(self.adm.get_asset_by_moniker('test3').get_color_set()
.equals(colorset3))
def test_all_assets(self):
reprs = [asset.__repr__() for asset in self.adm.get_all_assets()]
self.assertTrue(self.asset0.__repr__() in reprs)
self.assertTrue(self.asset1.__repr__() in reprs)
self.assertTrue(self.asset2.__repr__() in reprs)
def test_get_asset_and_address(self):
ch = self.asset1.get_color_set().get_color_hash()
addr = '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj'
coloraddress = "%[email protected]%s" % (ch, addr)
asset, address = self.adm.get_asset_and_address(coloraddress)
self.assertEquals(asset.__repr__(), self.asset1.__repr__())
self.assertEquals(addr, address)
asset, address = self.adm.get_asset_and_address(addr)
self.assertEquals(asset.__repr__(), self.asset0.__repr__())
self.assertEquals(addr, address)
self.assertRaises(Exception, self.adm.get_asset_and_address, '[email protected]')
示例6: AssetDefinition
# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import get_data [as 别名]
class AssetDefinition(object):
"""Stores the definition of a particular asset, including its color set,
it's name (moniker), and the wallet model that represents it.
"""
def __init__(self, colormap, params):
"""Create an Asset for a color map <colormap> and configuration
<params>. Note params has the color definitions used for this
Asset.
"""
self.colormap = colormap
self.monikers = params.get('monikers', [])
self.color_set = ColorSet(colormap, params.get('color_set'))
self.unit = int(params.get('unit', 1))
def __repr__(self):
return "%s: %s" % (self.monikers, self.color_set)
def get_monikers(self):
"""Returns the list of monikers for this asset.
"""
return self.monikers
def has_color_id(self, color_id):
return self.get_color_set().has_color_id(color_id)
def get_color_set(self):
"""Returns the list of colors for this asset.
"""
return self.color_set
def get_null_colorvalue(self):
color_set = self.get_color_set()
assert len(color_set.color_desc_list) == 1
cd = self.colormap.get_color_def(color_set.color_desc_list[0])
return SimpleColorValue(colordef=cd, value=0)
def get_colorvalue(self, utxo):
""" return colorvalue for a given utxo"""
if utxo.colorvalues:
for cv in utxo.colorvalues:
if self.has_color_id(cv.get_color_id()):
return cv
raise Exception("cannot get colorvalue for UTXO: "
"no colorvalues available")
def parse_value(self, portion):
"""Returns actual number of Satoshis for this Asset
given the <portion> of the asset.
"""
return int(float(portion) * self.unit)
def format_value(self, value):
"""Returns a string representation of the portion of the asset.
can involve rounding. doesn't display insignificant zeros
"""
if isinstance(value, ColorValue):
atoms = value.get_value()
else:
atoms = value
return '{0:g}'.format(atoms / float(self.unit))
def get_data(self):
"""Returns a JSON-compatible object that represents this Asset
"""
return {
"monikers": self.monikers,
"color_set": self.color_set.get_data(),
"unit": self.unit
}
示例7: AssetDefinition
# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import get_data [as 别名]
class AssetDefinition(object):
"""Stores the definition of a particular asset, including its color set,
it's name (moniker), and the wallet model that represents it.
"""
def __init__(self, colormap, params):
"""Create an Asset for a color map <colormap> and configuration
<params>. Note params has the color definitions used for this
Asset.
"""
self.colormap = colormap
self.monikers = params.get('monikers', [])
# currently only single-color assets are supported
assert len(params.get('color_set')) == 1
self.color_set = ColorSet(colormap, params.get('color_set'))
self.unit = int(params.get('unit', 1))
def __repr__(self):
return "%s: %s" % (self.monikers, self.color_set)
def get_id(self):
return self.color_set.get_color_hash()
def get_all_ids(self):
return [self.get_id()]
def get_monikers(self):
"""Returns the list of monikers for this asset.
"""
return self.monikers
def get_color_id(self):
return list(self.get_color_set().color_id_set)[0]
def has_color_id(self, color_id):
return self.get_color_set().has_color_id(color_id)
def get_color_set(self):
"""Returns the list of colors for this asset.
"""
return self.color_set
def get_color_def(self):
color_set = self.get_color_set()
assert len(color_set.color_desc_list) == 1
return self.colormap.get_color_def(color_set.color_desc_list[0])
def get_null_colorvalue(self):
cd = self.get_color_def()
return SimpleColorValue(colordef=cd, value=0)
def get_colorvalue(self, utxo):
""" return colorvalue for a given utxo"""
if utxo.colorvalues:
for cv in utxo.colorvalues:
if self.has_color_id(cv.get_color_id()):
return cv
raise Exception("Cannot get colorvalue for UTXO!")
def validate_value(self, portion):
"""Returns True if the portion is an exact multiple of the Asset atoms.
"""
if isinstance(portion, ColorValue) or isinstance(portion, AssetValue):
portion = portion.get_value()
atom = Decimal("1") / Decimal(self.unit)
return Decimal(portion) % atom == Decimal("0")
def parse_value(self, portion):
"""Returns actual number of Satoshis for this Asset
given the <portion> of the asset.
"""
return int(Decimal(portion) * Decimal(self.unit))
def format_value(self, value):
"""Returns a string representation of the portion of the asset.
can involve rounding. doesn't display insignificant zeros
"""
if isinstance(value, ColorValue) or isinstance(value, AssetValue):
value = value.get_value()
return str(Decimal(value) / Decimal(self.unit))
def get_atom(self):
return self.format_value(1)
def get_data(self):
"""Returns a JSON-compatible object that represents this Asset
"""
return {
"monikers": self.monikers,
"assetid" : self.get_color_set().get_color_hash(),
"color_set": self.color_set.get_data(),
"unit": self.unit
}
示例8: TestDeterministic
# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import get_data [as 别名]
class TestDeterministic(unittest.TestCase):
def setUp(self):
self.colormap = MockColorMap()
d = self.colormap.d
self.colorset0 = ColorSet(self.colormap, [''])
self.colorset1 = ColorSet(self.colormap, [d[1]])
self.colorset1alt = ColorSet(self.colormap, [d[1],d[6]])
self.colorset2 = ColorSet(self.colormap, [d[2]])
self.colorset3 = ColorSet(self.colormap, [d[3], d[4]])
self.def1 = {'monikers': ['test1'],
'color_set': self.colorset1.get_data(),
'unit':10}
self.asset1 = AssetDefinition(self.colormap, self.def1)
self.master_key = '265a1a0ad05e82fa321e3f6f6767679df0c68515797e0e4e24be1afc3272ee658ec53cecb683ab76a8377273347161e123fddf5320cbbce8849b0a00557bd12c'
self.privkey = '5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF'
self.pubkey = '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj'
c = {
'dw_master_key': self.master_key,
'dwam': {
'genesis_color_sets':[self.colorset1.get_data(),
self.colorset2.get_data()],
'color_set_states':[
{'color_set':self.colorset0.get_data(), "max_index":0},
{'color_set':self.colorset1.get_data(), "max_index":3},
{'color_set':self.colorset2.get_data(), "max_index":2},
],
},
'addresses':[{'address_data': self.privkey,
'color_set': self.colorset1.get_data(),
}],
'testnet': False,
}
self.config = copy.deepcopy(c)
self.maindwam = DWalletAddressManager(self.colormap, c)
def test_init_new_wallet(self):
c = copy.deepcopy(self.config)
del c['dw_master_key']
del c['dwam']
newdwam = DWalletAddressManager(self.colormap, c)
params = newdwam.init_new_wallet()
self.assertNotEqual(self.config['dw_master_key'],
newdwam.config['dw_master_key'])
c = copy.deepcopy(self.config)
c['addresses'][0]['address_data'] = 'notreal'
self.assertRaises(EncodingError, DWalletAddressManager,
self.colormap, c)
def test_get_new_address(self):
self.assertEqual(self.maindwam.get_new_address(self.colorset2).index,
3)
self.assertEqual(self.maindwam.get_new_address(self.asset1).index,
4)
def test_get_new_genesis_address(self):
addr = self.maindwam.get_new_genesis_address()
self.assertEqual(addr.index, 2)
addr2 = self.maindwam.get_new_address(addr.get_color_set())
self.assertEqual(addr2.index, 0)
def test_get_update_genesis_address(self):
addr = self.maindwam.get_genesis_address(0)
self.maindwam.update_genesis_address(addr, self.colorset1alt)
self.assertEqual(addr.get_color_set(), self.colorset1alt)
def test_get_change_address(self):
addr = self.maindwam.get_change_address(self.colorset0)
self.assertEqual(addr.get_color_set().__repr__(),
self.colorset0.__repr__())
self.assertEqual(self.maindwam.get_change_address(self.colorset3).index,
0)
def test_get_all_addresses(self):
addrs = [a.get_address() for a in self.maindwam.get_all_addresses()]
self.assertTrue(self.pubkey in addrs)
示例9: TestColorSet
# 需要导入模块: from coloredcoinlib import ColorSet [as 别名]
# 或者: from coloredcoinlib.ColorSet import get_data [as 别名]
class TestColorSet(unittest.TestCase):
def setUp(self):
self.colormap = MockColorMap()
d = self.colormap.d
self.colorset0 = ColorSet(self.colormap, [""])
self.colorset1 = ColorSet(self.colormap, [d[1]])
self.colorset2 = ColorSet(self.colormap, [d[2]])
self.colorset3 = ColorSet(self.colormap, [d[1], d[2]])
self.colorset4 = ColorSet(self.colormap, [d[3], d[2]])
self.colorset5 = ColorSet(self.colormap, [d[3], d[1]])
self.colorset6 = ColorSet(self.colormap, [])
def test_repr(self):
self.assertEquals(self.colorset0.__repr__(), "['']")
self.assertEquals(self.colorset1.__repr__(), "['obc:color_desc_1:0:0']")
self.assertEquals(self.colorset3.__repr__(), "['obc:color_desc_1:0:0', 'obc:color_desc_2:0:1']")
def test_uncolored_only(self):
self.assertTrue(self.colorset0.uncolored_only())
self.assertFalse(self.colorset1.uncolored_only())
self.assertFalse(self.colorset3.uncolored_only())
def test_get_data(self):
self.assertEquals(self.colorset0.get_data(), [""])
self.assertEquals(self.colorset1.get_data(), ["obc:color_desc_1:0:0"])
def test_get_hash_string(self):
self.assertEquals(
self.colorset0.get_hash_string(), "055539df4a0b804c58caf46c0cd2941af10d64c1395ddd8e50b5f55d945841e6"
)
self.assertEquals(
self.colorset1.get_hash_string(), "ca90284eaa79e05d5971947382214044fe64f1bdc2e97040cfa9f90da3964a14"
)
self.assertEquals(
self.colorset3.get_hash_string(), "09f731f25cf5bfaad512d4ee6f37cb9481f442df3263b15725dd1624b4678557"
)
def test_get_earliest(self):
self.assertEquals(self.colorset5.get_earliest(), "obc:color_desc_1:0:0")
self.assertEquals(self.colorset4.get_earliest(), "obc:color_desc_2:0:1")
self.assertEquals(self.colorset6.get_earliest(), "\x00\x00\x00\x00")
def test_get_color_string(self):
self.assertEquals(self.colorset1.get_color_hash(), "CP4YWLr8aAe4Hn")
self.assertEquals(self.colorset3.get_color_hash(), "ZUTSoEEwZY6PB")
def test_has_color_id(self):
self.assertTrue(self.colorset0.has_color_id(0))
self.assertTrue(self.colorset3.has_color_id(1))
self.assertFalse(self.colorset1.has_color_id(0))
self.assertFalse(self.colorset4.has_color_id(1))
def test_intersects(self):
self.assertFalse(self.colorset0.intersects(self.colorset1))
self.assertTrue(self.colorset1.intersects(self.colorset3))
self.assertTrue(self.colorset3.intersects(self.colorset1))
self.assertTrue(self.colorset4.intersects(self.colorset3))
self.assertFalse(self.colorset2.intersects(self.colorset0))
self.assertFalse(self.colorset1.intersects(self.colorset4))
def test_equals(self):
self.assertFalse(self.colorset1.equals(self.colorset0))
self.assertTrue(self.colorset3.equals(self.colorset3))
self.assertFalse(self.colorset4.equals(self.colorset5))
def test_from_color_ids(self):
self.assertTrue(self.colorset0.equals(ColorSet.from_color_ids(self.colormap, [0])))
self.assertTrue(self.colorset3.equals(ColorSet.from_color_ids(self.colormap, [1, 2])))
tmp = ColorSet.from_color_ids(self.colormap, [1, 2, 3])
self.assertTrue(tmp.has_color_id(1))
self.assertTrue(tmp.has_color_id(2))
self.assertTrue(tmp.has_color_id(3))