|
15 | 15 |
|
16 | 16 | import copy |
17 | 17 | import mock |
| 18 | +import uuid |
18 | 19 |
|
19 | 20 | from keystoneauth1 import access |
20 | 21 | from keystoneauth1 import fixture |
@@ -575,3 +576,66 @@ def setUp(self): |
575 | 576 | endpoint=fakes.AUTH_URL, |
576 | 577 | token=fakes.AUTH_TOKEN |
577 | 578 | ) |
| 579 | + |
| 580 | + |
| 581 | +class FakeProject(object): |
| 582 | + """Fake one or more project.""" |
| 583 | + |
| 584 | + @staticmethod |
| 585 | + def create_one_project(attrs=None): |
| 586 | + """Create a fake project. |
| 587 | +
|
| 588 | + :param Dictionary attrs: |
| 589 | + A dictionary with all attributes |
| 590 | + :return: |
| 591 | + A FakeResource object, with id, name, and so on |
| 592 | + """ |
| 593 | + |
| 594 | + attrs = attrs or {} |
| 595 | + |
| 596 | + # set default attributes. |
| 597 | + project_info = { |
| 598 | + 'id': 'project-id-' + uuid.uuid4().hex, |
| 599 | + 'name': 'project-name-' + uuid.uuid4().hex, |
| 600 | + 'description': 'project-description-' + uuid.uuid4().hex, |
| 601 | + 'enabled': True, |
| 602 | + 'is_domain': False, |
| 603 | + 'domain_id': 'domain-id-' + uuid.uuid4().hex, |
| 604 | + 'parent_id': 'parent-id-' + uuid.uuid4().hex, |
| 605 | + 'links': 'links-' + uuid.uuid4().hex, |
| 606 | + } |
| 607 | + project_info.update(attrs) |
| 608 | + |
| 609 | + project = fakes.FakeResource(info=copy.deepcopy(project_info), |
| 610 | + loaded=True) |
| 611 | + return project |
| 612 | + |
| 613 | + |
| 614 | +class FakeDomain(object): |
| 615 | + """Fake one or more domain.""" |
| 616 | + |
| 617 | + @staticmethod |
| 618 | + def create_one_domain(attrs=None): |
| 619 | + """Create a fake domain. |
| 620 | +
|
| 621 | + :param Dictionary attrs: |
| 622 | + A dictionary with all attributes |
| 623 | + :return: |
| 624 | + A FakeResource object, with id, name, and so on |
| 625 | + """ |
| 626 | + |
| 627 | + attrs = attrs or {} |
| 628 | + |
| 629 | + # set default attributes. |
| 630 | + domain_info = { |
| 631 | + 'id': 'domain-id-' + uuid.uuid4().hex, |
| 632 | + 'name': 'domain-name-' + uuid.uuid4().hex, |
| 633 | + 'description': 'domain-description-' + uuid.uuid4().hex, |
| 634 | + 'enabled': True, |
| 635 | + 'links': 'links-' + uuid.uuid4().hex, |
| 636 | + } |
| 637 | + domain_info.update(attrs) |
| 638 | + |
| 639 | + domain = fakes.FakeResource(info=copy.deepcopy(domain_info), |
| 640 | + loaded=True) |
| 641 | + return domain |
0 commit comments