本文整理汇总了Python中ralph.business.models.VentureRole.save方法的典型用法代码示例。如果您正苦于以下问题:Python VentureRole.save方法的具体用法?Python VentureRole.save怎么用?Python VentureRole.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ralph.business.models.VentureRole
的用法示例。
在下文中一共展示了VentureRole.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fisheye
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
def test_fisheye(self):
"""
Create Venture/Role and import as CI/CIRelations.
Now import fisheye xml from samples/* files and compare
if changes are properly saved into the database,
and reconcilated.
"""
x = Venture(symbol="test_venture")
x.save()
y = VentureRole(name="test_role", venture=x)
y.save()
allegro_ci = CI(name="Allegro", type_id=CI_TYPES.VENTURE.id)
allegro_ci.save()
ct = ContentType.objects.get_for_model(x)
test_venture, = CIImporter().import_all_ci([ct], asset_id=x.id)
ct = ContentType.objects.get_for_model(y)
test_role, = CIImporter().import_all_ci([ct], asset_id=y.id)
CIImporter().import_relations(ContentType.objects.get_for_model(y), asset_id=y.id)
with mock.patch("ralph.cmdb.integration.lib.fisheye.Fisheye") as Fisheye:
Fisheye.side_effect = MockFisheye
x = pgi(fisheye_class=Fisheye)
x.import_git()
self.assertEqual(
CIChangeGit.objects.filter(
author__contains="[email protected]",
# file_paths__contains='/test_venture'
).count(),
2,
)
self.assertEqual(CIChange.objects.filter(ci=test_role, type=CI_CHANGE_TYPES.CONF_GIT.id).count(), 2)
示例2: test_role_full_name
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
def test_role_full_name(self):
a = Venture(name='A', symbol='a')
a.save()
x = VentureRole(name='x', venture=a)
x.save()
y = VentureRole(name='y', venture=a, parent=x)
y.save()
self.assertEqual(y.full_name, 'x / y')
示例3: test_validate_venture_and_role
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
def test_validate_venture_and_role(self):
with self.assertRaises(forms.ValidationError):
_validate_venture_and_role('bang', 'klang', 0)
v = Venture(name='Bang', symbol='bang')
v.save()
with self.assertRaises(forms.ValidationError):
_validate_venture_and_role('bang', 'klang', 0)
r = VentureRole(name='klang', venture=v)
r.save()
_validate_venture_and_role('bang', 'klang', 0)
示例4: setUp
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
def setUp(self):
v = Venture(symbol='test_venture')
v.save()
r = VentureRole(name='test_role', venture=v)
r.save()
# ci for custom path mapping
c = Venture(symbol='custom_ci', name='custom_ci')
c.save()
for i in (v, r, c):
CIImporter().import_single_object(i)
CIImporter().import_single_object_relations(i)
示例5: setUp
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
def setUp(self):
self.client = login_as_su()
venture = Venture(name='venture', symbol='ventureSymbol')
venture.save()
self.venture = venture
venture_role = VentureRole(name='role', venture=self.venture)
venture_role.save()
self.venture_role = venture_role
d_kind = DeprecationKind(name='12 months', months=12)
d_kind.save()
self.kind = DeprecationKind.objects.get(name='12 months')
# Cross - devices
self.device_after_deprecation = Device.create(
sn='device_after_deprecation',
deprecation_kind=self.kind,
support_expiration_date=datetime.datetime(2003, 01, 02),
purchase_date=datetime.datetime(2001, 01, 01),
warranty_expiration_date=datetime.datetime(2005, 01, 02),
venture=self.venture,
venture_role=self.venture_role,
model_name='xxx',
model_type=DeviceType.unknown,
)
self.device_after_deprecation.name = 'Device1'
self.device_after_deprecation.save()
self.device_with_blanks = Device.create(
sn='device_with_blanks',
deprecation_date=None,
deprecation_kind=None,
support_expiration_date=None,
purchase_date=None,
venture=None,
venture_role=None,
model_name='xxx',
model_type=DeviceType.unknown,
)
self.device_with_blanks.name = 'Device2'
self.device_with_blanks.save()
示例6: setUp
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
def setUp(self):
login = 'ralph'
password = 'ralph'
user = User.objects.create_user(login, '[email protected]', password)
self.user = user
self.user.is_staff = True
self.user.is_superuser = True
self.user.save()
self.client = Client()
self.client.login(username=login, password=password)
venture = Venture(name=DEVICE_VENTURE, symbol=DEVICE_VENTURE_SYMBOL)
venture.save()
self.venture = venture
venture_role = VentureRole(name=VENTURE_ROLE, venture=self.venture)
venture_role.save()
self.venture_role = venture_role
self.device = Device.create(
sn=DEVICE_SN,
barcode=DEVICE_BARCODE,
remarks=DEVICE_REMARKS,
model_name='xxxx',
model_type=DeviceType.unknown,
venture=self.venture,
venture_role=self.venture_role,
rack=DEVICE_RACK,
position=DEVICE_POSITION,
dc=DATACENTER,
)
self.device.name = DEVICE_NAME
self.device.save()
self.layer = db.CILayer(name='layer1')
self.layer.save()
self.citype = db.CIType(name='xxx')
self.citype.save()
示例7: test_get_preboot_role_none
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
def test_get_preboot_role_none(self):
ven = Venture(name='test1', symbol='test1')
ven.save()
a = VentureRole(name='test1', venture_id = ven.id)
a.save()
b = VentureRole(name='test1 parent', parent_id = a.id, venture_id = ven.id)
b.save()
c = VentureRole(name='test1 parent parent', parent_id = b.id, venture_id = ven.id)
c.save()
self.assertEqual(a.get_preboot(), None)
self.assertEqual(b.get_preboot(), None)
self.assertEqual(c.get_preboot(), None)
示例8: test_get_preboot_role
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
def test_get_preboot_role(self):
preboot = Preboot(name='test preboot')
preboot.save()
ven = Venture(name='test1', symbol='test1', preboot = preboot)
ven.save()
a = VentureRole(name='test1', preboot = preboot, venture_id = ven.id)
a.save()
b = VentureRole(name='test1 parent', parent_id = a.id, venture_id = ven.id)
b.save()
c = VentureRole(name='test1 parent parent', parent_id = b.id, venture_id = ven.id)
c.save()
self.assertEqual(a.get_preboot(), preboot)
self.assertEqual(b.get_preboot(), preboot)
self.assertEqual(c.get_preboot(), preboot)
示例9: setUp
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
def setUp(self):
self.client = login_as_su()
venture = Venture(
name=DEVICE['venture'], symbol=DEVICE['ventureSymbol']
)
venture.save()
self.venture = venture
venture_role = VentureRole(
name=DEVICE['venture_role'], venture=self.venture
)
venture_role.save()
self.venture_role = venture_role
self.device = Device.create(
sn=DEVICE['sn'],
barcode=DEVICE['barcode'],
remarks=DEVICE['remarks'],
model_name=DEVICE['model_name'],
model_type=DeviceType.unknown,
venture=self.venture,
venture_role=self.venture_role,
rack=DEVICE['rack'],
position=DEVICE['position'],
dc=DATACENTER,
)
self.device.name = DEVICE['name']
self.device.save()
self.ip = IPAddress(address=DEVICE['ip'], device=self.device)
self.ip.save()
self.db_ip = IPAddress.objects.get(address=DEVICE['ip'])
self.network_terminator = NetworkTerminator(name='simple_terminator')
self.network_terminator.save()
self.network_datacenter = DataCenter(name=DATACENTER)
self.network_datacenter.save()
self.network = Network(
name=NETWORK['name'],
address=NETWORK['address'],
data_center=self.network_datacenter,
)
self.diskshare_device = Device.create(
sn=DISKSHARE['sn'],
barcode=DISKSHARE['barcode'],
model_name='xxx',
model_type=DeviceType.storage,
)
self.diskshare_device.name = DISKSHARE['device']
self.diskshare_device.save()
self.cm_generic = ComponentModel(name='GenericModel')
self.cm_diskshare = ComponentModel(name='DiskShareModel')
self.cm_processor = ComponentModel(name='ProcessorModel')
self.cm_memory = ComponentModel(name='MemoryModel')
self.cm_storage = ComponentModel(name='ComponentModel')
self.cm_fibre = ComponentModel(name='FibreChannalMidel')
self.cm_ethernet = ComponentModel(name='EthernetMidel')
self.cm_software = ComponentModel(name='SoftwareModel')
self.cm_splunkusage = ComponentModel(name='SplunkusageModel')
self.cm_operatingsystem = ComponentModel(name='OperatingSystemModel')
self.generic_component = GenericComponent(
device=self.device,
model=self.cm_generic,
label=COMPONENT['GenericComponent'],
sn=GENERIC['sn'],
)
self.generic_component.save()
self.diskshare = DiskShare(
device=self.device,
model=self.cm_diskshare,
share_id=self.device.id,
size=80,
wwn=DISKSHARE['wwn'],
)
self.diskshare.save()
self.disksharemount = DiskShareMount.concurrent_get_or_create(
share=self.diskshare,
device=self.device,
defaults={
'volume': COMPONENT['DiskShareMount'],
},
)
self.processor = Processor(
device=self.device,
model=self.cm_processor,
label=COMPONENT['Processor'],
)
self.processor.save()
self.memory = Memory(
device=self.device,
model=self.cm_memory,
label=COMPONENT['Memory'],
)
self.memory.save()
self.storage = Storage(
device=self.device,
model=self.cm_storage,
label=COMPONENT['Storage'],
)
self.storage.save()
self.fibrechannel = FibreChannel(
device=self.device,
model=self.cm_fibre,
label=COMPONENT['Fibre'],
#.........这里部分代码省略.........
示例10: CIImporterTest
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
class CIImporterTest(TestCase):
fixtures = ["0_types.yaml", "1_attributes.yaml", "2_layers.yaml", "3_prefixes.yaml"]
def setUp(self):
self.top_venture = Venture(name="top_venture")
self.top_venture.save()
self.child_venture = Venture(name="child_venture", parent=self.top_venture)
self.child_venture.save()
self.role = VentureRole(name="role", venture=self.child_venture)
self.role.save()
self.child_role = VentureRole(name="child_role", venture=self.child_venture, parent=self.role)
self.child_role.save()
dm = self.add_model("DC model sample", DeviceType.data_center.id)
self.dc = Device.create(sn="sn1", model=dm)
self.dc.name = "dc"
self.dc.save()
dm = self.add_model("Rack model sample", DeviceType.rack_server.id)
self.rack = Device.create(venture=self.child_venture, sn="sn2", model=dm)
self.rack.parent = self.dc
self.rack.name = "rack"
self.rack.save()
dm = self.add_model("Blade model sample", DeviceType.blade_server.id)
self.blade = Device.create(venture=self.child_venture, venturerole=self.child_role, sn="sn3", model=dm)
self.blade.name = "blade"
self.blade.parent = self.rack
self.blade.save()
def add_model(self, name, device_type):
dm = DeviceModel()
dm.model_type = (device_type,)
dm.name = name
dm.save()
return dm
def test_puppet_parser(self):
hostci = CI(name="s11401.dc2", uid="mm-1")
hostci.type_id = CI_TYPES.DEVICE.id
hostci.save()
p = PuppetAgentsImporter()
yaml = open(CURRENT_DIR + "cmdb/tests/samples/canonical.yaml").read()
p.import_contents(yaml)
yaml = open(CURRENT_DIR + "cmdb/tests/samples/canonical_unchanged.yaml").read()
p.import_contents(yaml)
chg = CIChange.objects.all()[0]
logs = PuppetLog.objects.filter(cichange__host="s11401.dc2").order_by("id")
self.assertEqual(chg.content_object.host, "s11401.dc2")
self.assertEqual(chg.content_object.kind, "apply")
self.assertEqual(chg.ci, hostci)
self.assertEqual(chg.type, 2)
# check parsed logs
self.assertEqual(len(logs), 16)
time_iso = logs[0].time.isoformat().split(".")[0]
self.assertEqual(time_iso, datetime.datetime(2010, 12, 31, 0, 56, 37).isoformat())
# should not import puppet report which has 'unchanged' status
self.assertEqual(CIChangePuppet.objects.filter(status="unchanged").count(), 0)
def test_fisheye(self):
"""
Create Venture/Role and import as CI/CIRelations.
Now import fisheye xml from samples/* files and compare
if changes are properly saved into the database,
and reconcilated.
"""
x = Venture(symbol="test_venture")
x.save()
y = VentureRole(name="test_role", venture=x)
y.save()
allegro_ci = CI(name="Allegro", type_id=CI_TYPES.VENTURE.id)
allegro_ci.save()
ct = ContentType.objects.get_for_model(x)
test_venture, = CIImporter().import_all_ci([ct], asset_id=x.id)
ct = ContentType.objects.get_for_model(y)
test_role, = CIImporter().import_all_ci([ct], asset_id=y.id)
CIImporter().import_relations(ContentType.objects.get_for_model(y), asset_id=y.id)
with mock.patch("ralph.cmdb.integration.lib.fisheye.Fisheye") as Fisheye:
Fisheye.side_effect = MockFisheye
x = pgi(fisheye_class=Fisheye)
x.import_git()
self.assertEqual(
CIChangeGit.objects.filter(
author__contains="[email protected]",
# file_paths__contains='/test_venture'
).count(),
2,
)
self.assertEqual(CIChange.objects.filter(ci=test_role, type=CI_CHANGE_TYPES.CONF_GIT.id).count(), 2)
# todo
# what if modified both core and venture?
def test_import_devices(self):
"""
#.........这里部分代码省略.........
示例11: DeploymentTest
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
class DeploymentTest(TestCase):
fixtures = ["0_types.yaml", "1_attributes.yaml", "2_layers.yaml", "3_prefixes.yaml"]
def setUp(self):
engine = settings.ISSUETRACKERS["default"]["ENGINE"]
if engine != "":
raise ImproperlyConfigured("""Expected ISSUETRACKERS['default']['ENGINE']='' got: %r""" % engine)
# usual stuff
self.top_venture = Venture(name="top_venture")
self.top_venture.save()
self.child_venture = Venture(name="child_venture", parent=self.top_venture)
self.child_venture.save()
self.role = VentureRole(name="role", venture=self.child_venture)
self.role.save()
self.child_role = VentureRole(name="child_role", venture=self.child_venture, parent=self.role)
self.child_role.save()
to = CIOwner(first_name="Bufallo", last_name="Kudłaczek")
to.save()
bo = CIOwner(first_name="Bill", last_name="Bąbelek")
bo.save()
ct = ContentType.objects.get_for_model(self.top_venture)
CIImporter().import_all_ci([ct])
CIOwnership(owner=to, ci=CI.get_by_content_object(self.child_venture), type=CIOwnershipType.technical.id).save()
CIOwnership(owner=bo, ci=CI.get_by_content_object(self.child_venture), type=CIOwnershipType.business.id).save()
dm = self.add_model("DC model sample", DeviceType.data_center.id)
self.dc = Device.create(sn="sn1", model=dm)
self.dc.name = "dc"
self.dc.save()
dm = self.add_model("Rack model sample", DeviceType.rack_server.id)
self.rack = Device.create(venture=self.child_venture, sn="sn2", model=dm)
self.rack.parent = self.dc
self.rack.name = "rack"
self.rack.save()
dm = self.add_model("Blade model sample", DeviceType.blade_server.id)
self.blade = Device.create(venture=self.child_venture, venturerole=self.child_role, sn="sn3", model=dm)
self.blade.name = "blade"
self.blade.parent = self.rack
self.blade.save()
self.deployment = Deployment()
self.deployment.hostname = "test_host2"
self.deployment.device = self.blade
self.deployment.mac = "10:9a:df:6f:af:01"
self.deployment.ip = "192.168.1.1"
self.deployment.hostname = "test"
self.deployment.save()
def test_acceptance(self):
# using issue null engine
self.assertEqual(self.deployment.status, DeploymentStatus.open.id)
self.deployment.create_issue()
self.assertEqual(self.deployment.issue_key, "#123456")
# status not changed, until plugin is run
self.assertEqual(self.deployment.status, DeploymentStatus.open.id)
# run ticket acceptance plugin
ticket(self.deployment.id)
# ticket already accepted
self.deployment = Deployment.objects.get(id=self.deployment.id)
self.assertEqual(self.deployment.status, DeploymentStatus.in_deployment.id)
def test_owners(self):
self.assertEqual(get_technical_owner(self.deployment.device), "bufallo.kudlaczek")
self.assertEqual(get_business_owner(self.deployment.device), "bill.babelek")
def add_model(self, name, device_type):
dm = DeviceModel()
dm.model_type = (device_type,)
dm.name = name
dm.save()
return dm
示例12: BulkeditTest
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
class BulkeditTest(TestCase):
""" Tests edit form
Scenario:
1. Changes data in single device + test history change
2. Changes data in more than one device
3. Send form without select edit fields
4. Send form with empty save comment field
5. If data was added, check depreciation_date
"""
def setUp(self):
self.client = login_as_su()
self.deprecation_kind = DeprecationKind(months=24, remarks='Default')
self.deprecation_kind.save()
self.margin = MarginKind(margin=100, remarks='100%')
self.margin.save()
self.venture = Venture(name='VenureName')
self.venture.save()
self.role = VentureRole(venture=self.venture, name='VentureRole')
self.role.save()
self.device = Device.create(
sn=DEVICE['sn'],
barcode=DEVICE['barcode'],
remarks=DEVICE['remarks'],
model_name=DEVICE['model_name'],
model_type=DeviceType.unknown,
rack=DEVICE['rack'],
position=DEVICE['position'],
dc=DATACENTER,
)
self.device.name = DEVICE['name']
self.device.save()
self.device2 = Device.create(
sn=DEVICE2['sn'],
barcode=DEVICE2['barcode'],
remarks=DEVICE2['remarks'],
model_name=DEVICE2['model_name'],
model_type=DeviceType.unknown,
rack=DEVICE2['rack'],
position=DEVICE2['position'],
dc=DATACENTER,
)
self.device2.name = DEVICE2['name']
self.device2.save()
def test_single_device_edit(self):
url = '/ui/search/bulkedit/'
select_fields = (
'venture', 'venture_role', 'margin_kind', 'deprecation_kind',
)
date_fields = (
'purchase_date', 'warranty_expiration_date',
'support_expiration_date', 'support_kind',
)
text_fields = (
'barcode', 'position', 'chassis_position', 'remarks', 'price',
'sn', 'verified'
)
device_fields = []
for field_list in [select_fields, date_fields, text_fields]:
device_fields.extend(field_list)
post_data = {
'select': [self.device.id], # 1
'edit': device_fields,
'venture': self.venture.id, # 1
'venture_role': self.role.id, # 1
'verified': True,
'barcode': 'bc-2222-2222-2222-2222',
'position': '9',
'chassis_position': 10,
'remarks': 'Hello Ralph',
'margin_kind': self.margin.id, # 1
'deprecation_kind': self.deprecation_kind.id, # 1
'price': 100,
'sn': '2222-2222-2222-2222',
'purchase_date': datetime(2001, 1, 1, 0, 0),
'warranty_expiration_date': datetime(2001, 1, 2, 0, 0),
'support_expiration_date': datetime(2001, 1, 3, 0, 0),
'support_kind': datetime(2001, 1, 4, 0, 0),
'save_comment': 'Everything has changed',
'save': '', # save form
}
response = self.client.post(url, post_data)
# Check if data from form is the same that data in database
device = Device.objects.get(id=self.device.id)
for field in device_fields:
db_data = getattr(device, field)
form_data = post_data[field]
#.........这里部分代码省略.........
示例13: CIImporterTest
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
class CIImporterTest(TestCase):
fixtures=['0_types.yaml', '1_attributes.yaml', '2_layers.yaml', '3_prefixes.yaml']
def setUp(self):
self.top_venture = Venture(name='top_venture')
self.top_venture.save()
self.child_venture = Venture(name='child_venture', parent=self.top_venture)
self.child_venture.save()
self.role = VentureRole(name='role', venture=self.child_venture)
self.role.save()
self.child_role = VentureRole(name='child_role',
venture=self.child_venture,
parent=self.role,
)
self.child_role.save()
dm = self.add_model('DC model sample', DeviceType.data_center.id)
self.dc = Device.create(sn='sn1', name='Rack 1', model=dm)
dm = self.add_model('Rack model sample', DeviceType.rack_server.id)
self.rack = Device.create(venture=self.child_venture, sn='sn2', name='DC', model=dm)
self.rack.parent=self.dc
self.rack.save()
dm = self.add_model('Blade model sample', DeviceType.blade_server.id)
self.blade = Device.create(
venture=self.child_venture,
venturerole=self.child_role,
sn='sn3',
name='blade1',
model=dm
)
self.blade.parent=self.rack
self.blade.save()
def add_model(self, name, device_type):
dm = DeviceModel();
dm.model_type=device_type,
dm.name=name
dm.save()
return dm
def test_puppet_parser(self):
hostci = CI(name='s11401.dc2', uid='mm-1')
hostci.type_id = CI_TYPES.DEVICE.id
hostci.save()
p = PuppetAgentsImporter()
yaml = open(os.getcwd()+'/cmdb/tests/samples/canonical.yaml').read()
p.import_contents(yaml)
yaml = open(os.getcwd()+'/cmdb/tests/samples/canonical_unchanged.yaml').read()
p.import_contents(yaml)
chg = CIChange.objects.all()[0]
logs = PuppetLog.objects.filter(cichange=chg).order_by('id')
self.assertEqual(chg.content_object.host, u's11401.dc2')
self.assertEqual(chg.content_object.kind, u'apply')
self.assertEqual(chg.ci,hostci)
self.assertEqual(chg.type, 2)
# check parsed logs
self.assertEqual(len(logs), 16)
self.assertEqual(logs[0].time, datetime.datetime(2010, 12, 31, 0, 56, 37, 290413))
# should not import puppet report which has 'unchanged' status
self.assertEqual(CIChangePuppet.objects.filter(status='unchanged').count(), 0)
def test_fisheye(self):
"""
Create Venture/Role and import as CI/CIRelations.
Now import fisheye xml from samples/* files and compare
if changes are properly saved into the database,
and reconcilated.
"""
x = Venture(symbol='test_venture')
x.save()
y = VentureRole(name='test_role', venture=x)
y.save()
allegro_ci = CI(name='Allegro', type_id=CI_TYPES.VENTURE.id)
allegro_ci.save()
ct=ContentType.objects.get_for_model(x)
test_venture, = CIImporter.import_all_ci([ct],asset_id=x.id)
ct=ContentType.objects.get_for_model(y)
test_role, = CIImporter.import_all_ci([ct],asset_id=y.id)
CIImporter.import_relations(ContentType.objects.get_for_model(y),asset_id=y.id)
with mock.patch('ralph.cmdb.integration.fisheye.Fisheye') as Fisheye:
Fisheye.side_effect = MockFisheye
x = pgi(fisheye_class=Fisheye)
x.import_git()
self.assertEqual(CIChangeGit.objects.filter(
author__contains='[email protected]',
#file_paths__contains='/test_venture'
).count(), 2)
self.assertEqual(CIChange.objects.filter(
ci=test_role,
type=CI_CHANGE_TYPES.CONF_GIT.id,
).count(), 2)
#.........这里部分代码省略.........
示例14: DeploymentTest
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
class DeploymentTest(TestCase):
fixtures=['0_types.yaml', '1_attributes.yaml', '2_layers.yaml', '3_prefixes.yaml']
def setUp(self):
engine = settings.ISSUETRACKERS['default']['ENGINE']
if engine != '':
raise ImproperlyConfigured('''Expected ISSUETRACKERS['default']['ENGINE']='' got: %s''' % engine)
# usual stuff
self.top_venture = Venture(name='top_venture')
self.top_venture.save()
self.child_venture = Venture(name='child_venture', parent=self.top_venture)
self.child_venture.save()
self.role = VentureRole(name='role', venture=self.child_venture)
self.role.save()
self.child_role = VentureRole(name='child_role',
venture=self.child_venture,
parent=self.role,
)
self.child_role.save()
to = VentureOwner(name='Bufallo Kudłaczek', venture=self.child_venture, type=OwnerType.technical.id)
to.save()
bo = VentureOwner(name='Bill Bąbelek', venture=self.child_venture, type=OwnerType.business.id)
bo.save()
dm = self.add_model('DC model sample', DeviceType.data_center.id)
self.dc = Device.create(
sn='sn1',
model=dm
)
self.dc.name = 'dc'
self.dc.save()
dm = self.add_model('Rack model sample', DeviceType.rack_server.id)
self.rack = Device.create(
venture=self.child_venture,
sn='sn2',
model=dm
)
self.rack.parent=self.dc
self.rack.name = 'rack'
self.rack.save()
dm = self.add_model('Blade model sample', DeviceType.blade_server.id)
self.blade = Device.create(
venture=self.child_venture,
venturerole=self.child_role,
sn='sn3',
model=dm
)
self.blade.name = 'blade'
self.blade.parent=self.rack
self.blade.save()
self.deployment = Deployment()
self.deployment.hostname = 'test_host2'
self.deployment.device=self.blade
self.deployment.mac = '10:9a:df:6f:af:01'
self.deployment.ip='192.168.1.1'
self.deployment.hostname='test'
self.deployment.save()
def test_acceptance(self):
# using issue null engine
self.assertEqual(self.deployment.status, DeploymentStatus.open.id)
self.deployment.create_issue()
self.assertEqual(self.deployment.issue_key, '#123456')
# status not changed, until plugin is run
self.assertEqual(self.deployment.status, DeploymentStatus.open.id)
# run ticket acceptance plugin
ticket(self.deployment.id)
# ticket already accepted
self.deployment = Deployment.objects.get(id=self.deployment.id)
self.assertEqual(self.deployment.status, DeploymentStatus.in_deployment.id)
def test_owners(self):
self.assertEqual(get_technical_owner(self.deployment.device), 'bufallo.kudlaczek')
self.assertEqual(get_business_owner(self.deployment.device), 'bill.babelek')
def add_model(self, name, device_type):
dm = DeviceModel();
dm.model_type=device_type,
dm.name=name
dm.save()
return dm
示例15: test_check_ip
# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import save [as 别名]
def test_check_ip(self):
terminator = NetworkTerminator(name='Test Terminator')
terminator.save()
data_center = DataCenter(name='Test date_center')
data_center.save()
network = Network(address='192.168.1.0/24',name='Test network',
data_center=data_center)
network.save()
network.terminators = [terminator]
network.save()
subnetwork = Network(address='192.168.2.0/24',name='Test subnetwork',
data_center=data_center)
subnetwork.save()
subnetwork.terminators = [terminator]
subnetwork.save()
main_venture = Venture(name='Main Venture')
main_venture.save()
main_venture.networks = [network, subnetwork]
main_venture.save()
second_network = Network(address='172.16.0.0/28',name='Test secound_network',
data_center=data_center)
second_network.save()
second_network.terminators = [terminator]
second_network.save()
child_venture = Venture(name='Child Venture', parent=main_venture)
child_venture.save()
child_venture.networks = [second_network]
child_venture.save()
third_network = Network(address='66.6.6.0/29',name='Test third_network',
data_center=data_center)
third_network.save()
third_network.terminators = [terminator]
third_network.save()
third_subnetwork = Network(address='66.6.7.0/29',name='Test third_subnetwork',
data_center=data_center)
third_subnetwork.save()
third_subnetwork.terminators = [terminator]
third_subnetwork.save()
venture_role_main = VentureRole(name='Main Venture role',
venture=child_venture)
venture_role_main.save()
venture_role_main.networks = [third_network, third_subnetwork]
venture_role_main.save()
fourth_network = Network(address='111.11.11.0/27',name='Test fourth_network',
data_center=data_center)
fourth_network.save()
fourth_network.terminators = [terminator]
fourth_network.save()
venture_role_child = VentureRole(name='Child Venture role',
venture=child_venture,
parent=venture_role_main)
venture_role_child.save()
venture_role_child.networks = [fourth_network]
venture_role_child.save()
self.assertEqual(venture_role_child.check_ip("192.168.1.15"), True)
self.assertEqual(venture_role_child.check_ip("192.168.2.15"), True)
self.assertEqual(venture_role_child.check_ip("192.168.3.15"), False)
self.assertEqual(venture_role_child.check_ip("172.16.0.10"), True)
self.assertEqual(venture_role_child.check_ip("172.16.0.22"), False)
self.assertEqual(venture_role_child.check_ip("66.6.6.5"), True)
self.assertEqual(venture_role_child.check_ip("66.6.7.5"), True)
self.assertEqual(venture_role_child.check_ip("66.6.8.10"), False)
self.assertEqual(venture_role_child.check_ip("111.11.11.1"), True)
self.assertEqual(venture_role_child.check_ip("111.11.11.44"), False)