-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Domain ID has been commented out as not implemented yet, to be added back in once project creation action has a domain id parameter
- Loading branch information
Showing
5 changed files
with
46 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,18 +45,18 @@ def test_create_project_invalid_email_throws(): | |
create_project(mock_conn, mock_project_details) | ||
|
||
|
||
def test_create_project_domain_missing_throws(): | ||
""" | ||
Tests calling the API wrapper without a project domain will throw | ||
""" | ||
mock_project_details = MagicMock() | ||
mock_project_details.name = "foo" | ||
mock_project_details.email = "[email protected]" | ||
mock_project_details.project_domain = None | ||
# def test_create_project_domain_missing_throws(): | ||
# """ | ||
# Tests calling the API wrapper without a project domain will throw | ||
# """ | ||
# mock_project_details = MagicMock() | ||
# mock_project_details.name = "foo" | ||
# mock_project_details.email = "[email protected]" | ||
# mock_project_details.project_domain = None | ||
|
||
mock_conn = MagicMock() | ||
with pytest.raises(ValueError): | ||
create_project(mock_conn, mock_project_details) | ||
# mock_conn = MagicMock() | ||
# with pytest.raises(ValueError): | ||
# create_project(mock_conn, mock_project_details) | ||
|
||
|
||
def test_create_project_forwards_error(): | ||
|
@@ -74,34 +74,34 @@ def test_create_project_forwards_error(): | |
create_project(mock_conn, mock_project_details) | ||
|
||
|
||
def test_get_domain_called(): | ||
""" | ||
Tests that get_domain is called when creating a project | ||
""" | ||
# def test_get_domain_called(): | ||
# """ | ||
# Tests that get_domain is called when creating a project | ||
# """ | ||
|
||
mock_project_details = MagicMock() | ||
mock_project_details.name = "foo" | ||
mock_project_details.description = "bar" | ||
mock_project_details.project_domain = "test-domain" | ||
mock_project_details.is_enabled = True | ||
mock_project_details.email = "[email protected]" | ||
mock_project_details.parent_id = None | ||
mock_project_details.immutable = False | ||
# mock_project_details = MagicMock() | ||
# mock_project_details.name = "foo" | ||
# mock_project_details.description = "bar" | ||
# mock_project_details.project_domain = "test-domain" | ||
# mock_project_details.is_enabled = True | ||
# mock_project_details.email = "[email protected]" | ||
# mock_project_details.parent_id = None | ||
# mock_project_details.immutable = False | ||
|
||
mock_conn = MagicMock() | ||
# mock_conn = MagicMock() | ||
|
||
create_project(mock_conn, mock_project_details) | ||
mock_conn.identity.get_domain.assert_called_once_with("test-domain") | ||
# create_project(mock_conn, mock_project_details) | ||
# mock_conn.identity.get_domain.assert_called_once_with("test-domain") | ||
|
||
|
||
def test_create_project_successful(): | ||
""" | ||
Tests that create project works without a domain id | ||
Tests that create project works | ||
""" | ||
mock_project_details = MagicMock() | ||
mock_project_details.name = "foo" | ||
mock_project_details.description = "bar" | ||
mock_project_details.project_domain = "test-domain" | ||
# mock_project_details.project_domain = "test-domain" | ||
mock_project_details.is_enabled = True | ||
mock_project_details.email = "[email protected]" | ||
mock_project_details.parent_id = None | ||
|
@@ -111,16 +111,15 @@ def test_create_project_successful(): | |
|
||
res = create_project(mock_conn, mock_project_details) | ||
|
||
mock_conn.identity.get_domain.assert_called_once_with("test-domain") | ||
# mock_conn.identity.get_domain.assert_called_once_with("test-domain") | ||
|
||
domain_details = mock_conn.identity.get_domain(mock_project_details.project_domain) | ||
domain_id = domain_details.id | ||
# domain_details = mock_conn.identity.get_domain(mock_project_details.project_domain) | ||
# domain_id = domain_details.id | ||
|
||
mock_conn.identity.create_project.assert_called_once_with( | ||
name="foo", | ||
description="bar", | ||
is_enabled=True, | ||
domain_id=domain_id, | ||
tags=["[email protected]"], | ||
) | ||
assert res == mock_conn.identity.create_project.return_value | ||
|
@@ -133,7 +132,7 @@ def test_create_project_successful_no_parent_id_and_not_immutable(): | |
mock_project_details = MagicMock() | ||
mock_project_details.name = "foo" | ||
mock_project_details.description = "bar" | ||
mock_project_details.project_domain = "buzz" | ||
# mock_project_details.project_domain = "buzz" | ||
mock_project_details.is_enabled = True | ||
mock_project_details.email = "[email protected]" | ||
mock_project_details.parent_id = None | ||
|
@@ -143,15 +142,14 @@ def test_create_project_successful_no_parent_id_and_not_immutable(): | |
|
||
res = create_project(mock_conn, mock_project_details) | ||
|
||
mock_conn.identity.get_domain.assert_called_once_with("buzz") | ||
# mock_conn.identity.get_domain.assert_called_once_with("buzz") | ||
|
||
domain_details = mock_conn.identity.get_domain(mock_project_details.project_domain) | ||
domain_id = domain_details.id | ||
# domain_details = mock_conn.identity.get_domain(mock_project_details.project_domain) | ||
# domain_id = domain_details.id | ||
|
||
mock_conn.identity.create_project.assert_called_once_with( | ||
name="foo", | ||
description="bar", | ||
domain_id=domain_id, | ||
is_enabled=True, | ||
tags=["[email protected]"], | ||
) | ||
|
@@ -166,7 +164,7 @@ def test_create_project_successful_with_parent_id_and_immutable(): | |
mock_project_details = MagicMock() | ||
mock_project_details.name = "foo" | ||
mock_project_details.description = "bar" | ||
mock_project_details.project_domain = "buzz" | ||
# mock_project_details.project_domain = "buzz" | ||
mock_project_details.is_enabled = True | ||
mock_project_details.email = "[email protected]" | ||
mock_project_details.parent_id = "baz" | ||
|
@@ -176,15 +174,14 @@ def test_create_project_successful_with_parent_id_and_immutable(): | |
|
||
res = create_project(mock_conn, mock_project_details) | ||
|
||
mock_conn.identity.get_domain.assert_called_once_with("buzz") | ||
# mock_conn.identity.get_domain.assert_called_once_with("buzz") | ||
|
||
domain_details = mock_conn.identity.get_domain(mock_project_details.project_domain) | ||
domain_id = domain_details.id | ||
# domain_details = mock_conn.identity.get_domain(mock_project_details.project_domain) | ||
# domain_id = domain_details.id | ||
|
||
mock_conn.identity.create_project.assert_called_once_with( | ||
name="foo", | ||
description="bar", | ||
domain_id=domain_id, | ||
is_enabled=True, | ||
parent_id="baz", | ||
tags=["[email protected]", "immutable"], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,6 @@ def test_create_jasmin_external_project( | |
mock_conn = MagicMock() | ||
project_name = "Test Project" | ||
project_email = "[email protected]" | ||
project_domain = "test-domain" | ||
project_description = "Test Description" | ||
network_name = "External Network" | ||
subnet_name = "External Subnet" | ||
|
@@ -72,7 +71,6 @@ def test_create_jasmin_external_project( | |
mock_conn, | ||
project_name, | ||
project_email, | ||
project_domain, | ||
project_description, | ||
network_name, | ||
subnet_name, | ||
|
@@ -91,7 +89,6 @@ def test_create_jasmin_external_project( | |
ProjectDetails( | ||
name=project_name, | ||
email=project_email, | ||
project_domain=project_domain, | ||
description=project_description, | ||
immutable=project_immutable, | ||
parent_id=parent_id, | ||
|
@@ -256,7 +253,7 @@ def test_create_jasmin_external_project_no_users( | |
mock_conn = MagicMock() | ||
project_name = "Test Project" | ||
project_email = "[email protected]" | ||
project_domain = "test-domain" | ||
# project_domain = "test-domain" | ||
project_description = "Test Description" | ||
network_name = "External Network" | ||
subnet_name = "External Subnet" | ||
|
@@ -273,7 +270,6 @@ def test_create_jasmin_external_project_no_users( | |
mock_conn, | ||
project_name, | ||
project_email, | ||
project_domain, | ||
project_description, | ||
network_name, | ||
subnet_name, | ||
|
@@ -292,7 +288,6 @@ def test_create_jasmin_external_project_no_users( | |
ProjectDetails( | ||
name=project_name, | ||
email=project_email, | ||
project_domain=project_domain, | ||
description=project_description, | ||
immutable=project_immutable, | ||
parent_id=parent_id, | ||
|