Skip to content

Commit 83fbce4

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Remove fake methods code from compute network"
2 parents 5b18e11 + a281ef8 commit 83fbce4

1 file changed

Lines changed: 15 additions & 77 deletions

File tree

  • openstackclient/tests/compute/v2

openstackclient/tests/compute/v2/fakes.py

Lines changed: 15 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -342,20 +342,16 @@ class FakeSecurityGroup(object):
342342
"""Fake one or more security groups."""
343343

344344
@staticmethod
345-
def create_one_security_group(attrs=None, methods=None):
345+
def create_one_security_group(attrs=None):
346346
"""Create a fake security group.
347347
348348
:param Dictionary attrs:
349349
A dictionary with all attributes
350-
:param Dictionary methods:
351-
A dictionary with all methods
352350
:return:
353351
A FakeResource object, with id, name, etc.
354352
"""
355353
if attrs is None:
356354
attrs = {}
357-
if methods is None:
358-
methods = {}
359355

360356
# Set default attributes.
361357
security_group_attrs = {
@@ -369,28 +365,17 @@ def create_one_security_group(attrs=None, methods=None):
369365
# Overwrite default attributes.
370366
security_group_attrs.update(attrs)
371367

372-
# Set default methods.
373-
security_group_methods = {
374-
'keys': ['id', 'name', 'description', 'tenant_id', 'rules'],
375-
}
376-
377-
# Overwrite default methods.
378-
security_group_methods.update(methods)
379-
380368
security_group = fakes.FakeResource(
381369
info=copy.deepcopy(security_group_attrs),
382-
methods=copy.deepcopy(security_group_methods),
383370
loaded=True)
384371
return security_group
385372

386373
@staticmethod
387-
def create_security_groups(attrs=None, methods=None, count=2):
374+
def create_security_groups(attrs=None, count=2):
388375
"""Create multiple fake security groups.
389376
390377
:param Dictionary attrs:
391378
A dictionary with all attributes
392-
:param Dictionary methods:
393-
A dictionary with all methods
394379
:param int count:
395380
The number of security groups to fake
396381
:return:
@@ -399,7 +384,7 @@ def create_security_groups(attrs=None, methods=None, count=2):
399384
security_groups = []
400385
for i in range(0, count):
401386
security_groups.append(
402-
FakeSecurityGroup.create_one_security_group(attrs, methods))
387+
FakeSecurityGroup.create_one_security_group(attrs))
403388

404389
return security_groups
405390

@@ -408,20 +393,16 @@ class FakeSecurityGroupRule(object):
408393
"""Fake one or more security group rules."""
409394

410395
@staticmethod
411-
def create_one_security_group_rule(attrs=None, methods=None):
396+
def create_one_security_group_rule(attrs=None):
412397
"""Create a fake security group rule.
413398
414399
:param Dictionary attrs:
415400
A dictionary with all attributes
416-
:param Dictionary methods:
417-
A dictionary with all methods
418401
:return:
419402
A FakeResource object, with id, etc.
420403
"""
421404
if attrs is None:
422405
attrs = {}
423-
if methods is None:
424-
methods = {}
425406

426407
# Set default attributes.
427408
security_group_rule_attrs = {
@@ -437,26 +418,17 @@ def create_one_security_group_rule(attrs=None, methods=None):
437418
# Overwrite default attributes.
438419
security_group_rule_attrs.update(attrs)
439420

440-
# Set default methods.
441-
security_group_rule_methods = {}
442-
443-
# Overwrite default methods.
444-
security_group_rule_methods.update(methods)
445-
446421
security_group_rule = fakes.FakeResource(
447422
info=copy.deepcopy(security_group_rule_attrs),
448-
methods=copy.deepcopy(security_group_rule_methods),
449423
loaded=True)
450424
return security_group_rule
451425

452426
@staticmethod
453-
def create_security_group_rules(attrs=None, methods=None, count=2):
427+
def create_security_group_rules(attrs=None, count=2):
454428
"""Create multiple fake security group rules.
455429
456430
:param Dictionary attrs:
457431
A dictionary with all attributes
458-
:param Dictionary methods:
459-
A dictionary with all methods
460432
:param int count:
461433
The number of security group rules to fake
462434
:return:
@@ -465,8 +437,7 @@ def create_security_group_rules(attrs=None, methods=None, count=2):
465437
security_group_rules = []
466438
for i in range(0, count):
467439
security_group_rules.append(
468-
FakeSecurityGroupRule.create_one_security_group_rule(
469-
attrs, methods))
440+
FakeSecurityGroupRule.create_one_security_group_rule(attrs))
470441

471442
return security_group_rules
472443

@@ -688,13 +659,11 @@ class FakeAvailabilityZone(object):
688659
"""Fake one or more compute availability zones (AZs)."""
689660

690661
@staticmethod
691-
def create_one_availability_zone(attrs={}, methods={}):
662+
def create_one_availability_zone(attrs={}):
692663
"""Create a fake AZ.
693664
694665
:param Dictionary attrs:
695666
A dictionary with all attributes
696-
:param Dictionary methods:
697-
A dictionary with all methods
698667
:return:
699668
A FakeResource object with zoneName, zoneState, etc.
700669
"""
@@ -717,18 +686,15 @@ def create_one_availability_zone(attrs={}, methods={}):
717686

718687
availability_zone = fakes.FakeResource(
719688
info=copy.deepcopy(availability_zone),
720-
methods=methods,
721689
loaded=True)
722690
return availability_zone
723691

724692
@staticmethod
725-
def create_availability_zones(attrs={}, methods={}, count=2):
693+
def create_availability_zones(attrs={}, count=2):
726694
"""Create multiple fake AZs.
727695
728696
:param Dictionary attrs:
729697
A dictionary with all attributes
730-
:param Dictionary methods:
731-
A dictionary with all methods
732698
:param int count:
733699
The number of AZs to fake
734700
:return:
@@ -737,8 +703,7 @@ def create_availability_zones(attrs={}, methods={}, count=2):
737703
availability_zones = []
738704
for i in range(0, count):
739705
availability_zone = \
740-
FakeAvailabilityZone.create_one_availability_zone(
741-
attrs, methods)
706+
FakeAvailabilityZone.create_one_availability_zone(attrs)
742707
availability_zones.append(availability_zone)
743708

744709
return availability_zones
@@ -748,13 +713,11 @@ class FakeFloatingIP(object):
748713
"""Fake one or more floating ip."""
749714

750715
@staticmethod
751-
def create_one_floating_ip(attrs={}, methods={}):
716+
def create_one_floating_ip(attrs={}):
752717
"""Create a fake floating ip.
753718
754719
:param Dictionary attrs:
755720
A dictionary with all attributes
756-
:param Dictionary methods:
757-
A dictionary with all methods
758721
:return:
759722
A FakeResource object, with id, ip, and so on
760723
"""
@@ -770,38 +733,26 @@ def create_one_floating_ip(attrs={}, methods={}):
770733
# Overwrite default attributes.
771734
floating_ip_attrs.update(attrs)
772735

773-
# Set default methods.
774-
floating_ip_methods = {}
775-
776-
# Overwrite default methods.
777-
floating_ip_methods.update(methods)
778-
779736
floating_ip = fakes.FakeResource(
780737
info=copy.deepcopy(floating_ip_attrs),
781-
methods=copy.deepcopy(floating_ip_methods),
782738
loaded=True)
783739

784740
return floating_ip
785741

786742
@staticmethod
787-
def create_floating_ips(attrs={}, methods={}, count=2):
743+
def create_floating_ips(attrs={}, count=2):
788744
"""Create multiple fake floating ips.
789745
790746
:param Dictionary attrs:
791747
A dictionary with all attributes
792-
:param Dictionary methods:
793-
A dictionary with all methods
794748
:param int count:
795749
The number of floating ips to fake
796750
:return:
797751
A list of FakeResource objects faking the floating ips
798752
"""
799753
floating_ips = []
800754
for i in range(0, count):
801-
floating_ips.append(FakeFloatingIP.create_one_floating_ip(
802-
attrs,
803-
methods
804-
))
755+
floating_ips.append(FakeFloatingIP.create_one_floating_ip(attrs))
805756
return floating_ips
806757

807758
@staticmethod
@@ -828,13 +779,11 @@ class FakeNetwork(object):
828779
"""Fake one or more networks."""
829780

830781
@staticmethod
831-
def create_one_network(attrs={}, methods={}):
782+
def create_one_network(attrs={}):
832783
"""Create a fake network.
833784
834785
:param Dictionary attrs:
835786
A dictionary with all attributes
836-
:param Dictionary methods:
837-
A dictionary with all methods
838787
:return:
839788
A FakeResource object, with id, label, cidr and so on
840789
"""
@@ -877,36 +826,25 @@ def create_one_network(attrs={}, methods={}):
877826
# Overwrite default attributes.
878827
network_attrs.update(attrs)
879828

880-
# Set default methods.
881-
network_methods = {
882-
'keys': ['id', 'label', 'cidr'],
883-
}
884-
885-
# Overwrite default methods.
886-
network_methods.update(methods)
887-
888829
network = fakes.FakeResource(info=copy.deepcopy(network_attrs),
889-
methods=copy.deepcopy(network_methods),
890830
loaded=True)
891831

892832
return network
893833

894834
@staticmethod
895-
def create_networks(attrs={}, methods={}, count=2):
835+
def create_networks(attrs={}, count=2):
896836
"""Create multiple fake networks.
897837
898838
:param Dictionary attrs:
899839
A dictionary with all attributes
900-
:param Dictionary methods:
901-
A dictionary with all methods
902840
:param int count:
903841
The number of networks to fake
904842
:return:
905843
A list of FakeResource objects faking the networks
906844
"""
907845
networks = []
908846
for i in range(0, count):
909-
networks.append(FakeNetwork.create_one_network(attrs, methods))
847+
networks.append(FakeNetwork.create_one_network(attrs))
910848

911849
return networks
912850

0 commit comments

Comments
 (0)