Exemple #1
0
def test_delete():
    responses.add(responses.DELETE, 'http://api/v2/licenses/777', status=204)
    manager = LicenseManager(client)

    result = manager.delete(license_id=777)

    assert result is None
Exemple #2
0
def test_delete_multiple_with_raise():
    responses.add(responses.DELETE, 'http://api/v2/licenses/100', status=204)
    responses.add(responses.DELETE, 'http://api/v2/licenses/200', status=404)

    manager = LicenseManager(client)

    with pytest.raises(ClientException):
        manager.delete_many(license_ids=[100, 200])
Exemple #3
0
def test_add():
    responses.add(responses.POST,
                  'http://api/v2/licenses/projects/666',
                  json=answers.LICENSES_CREATE)
    manager = LicenseManager(client)

    licenses = manager.add(project_id=666, licenses=params.licenses)

    assert len(licenses) > 0
Exemple #4
0
def test_list():
    responses.add(responses.GET,
                  'http://api/v2/licenses',
                  json=answers.LICENSES_LIST)
    manager = LicenseManager(client)

    licenses = manager.list(return_raw=True)

    assert licenses == answers.LICENSES_LIST["licenses"]
Exemple #5
0
def test_list():
    responses.add(responses.GET,
                  'http://api/v2/licenses',
                  json=answers.LICENSES_LIST)
    manager = LicenseManager(client)

    licenses = manager.list()

    assert len(licenses) == 2
Exemple #6
0
def test_show():
    responses.add(responses.GET,
                  'http://api/v2/licenses/awesome_id',
                  json=answers.LICENSES_SHOW)
    manager = LicenseManager(client)

    license = manager.show(license_id="awesome_id")

    assert license is not None
    assert license.id == 420
Exemple #7
0
def test_licenses_partial_resp():
    responses.add(responses.POST,
                  'http://api/v2/licenses/projects/666',
                  json=answers.LICENSES_PARTIAL,
                  status=207)
    manager = LicenseManager(client)

    licenses = manager.add(project_id=666, licenses=params.licenses)

    assert len(licenses) == 1
    assert [lic._info for lic in licenses] == answers.LICENSES_PARTIAL_RESULT
Exemple #8
0
def test_delete_from_single_obj():
    responses.add(responses.GET,
                  'http://api/v2/licenses',
                  json=answers.LICENSES_LIST)
    responses.add(responses.DELETE, 'http://api/v2/licenses/0', status=204)
    manager = LicenseManager(client)

    license = manager.list()[0]
    result = license.delete()

    assert result is None
 def __init__(self, client):
     super(ProjectsManager, self).__init__(client)
     self.roles_manager = RolesManager(client)
     self.quotas_manager = QuotasManager(client)
     self.licenses_manager = LicenseManager(client)
     self.token_manager = TokensManager(client)
     self.subnets_manager = SubnetManager(client)
     self.fips_manager = FloatingIPManager(client)
Exemple #10
0
def test_list_with_filters():
    responses.add(responses.GET,
                  'http://api/v2/licenses',
                  json=answers.LICENSES_LIST)
    manager = LicenseManager(client)

    ips = manager.list(project_id="e7081cb46966421fb8b3f3fd9b4db75b")
    assert len(ips) == 1
    assert ips[0]["project_id"] == "e7081cb46966421fb8b3f3fd9b4db75b"

    ips = manager.list(region="ru-2")
    assert len(ips) == 1
    assert ips[0]["region"] == "ru-2"

    ips = manager.list(project_id="e7081cb46966421fb8b3f3fd9b4db75b",
                       region="ru-2")
    assert len(ips) == 0
Exemple #11
0
 def __init__(self, client):
     self.projects = ProjectsManager(client)
     self.quotas = QuotasManager(client)
     self.users = UsersManager(client)
     self.licenses = LicenseManager(client)
     self.roles = RolesManager(client)
     self.floatingips = FloatingIPManager(client)
     self.subnets = SubnetManager(client)
     self.vrrp = VRRPManager(client)
     self.capabilities = CapabilitiesManager(client)
     self.tokens = TokensManager(client)
     self.customization = CustomizationManager(client)