'Tests the NameSpace creation and deletion functionality:
* Actions:
* 1) Login to Horizon Dashboard as admin user.
* 2) Navigate to Admin -> System -> Metadata Definitions.
* 3) Click "Import Namespace" button. Wait for Create Network dialog.
* 4) Enter settings for new Namespace:
*   - Namespace Definition Source: \'raw\' or \'file\'
*   - Namespace JSON location;
*   - Public: Yes  or No;
*   - Protected: No (check box not enabled).
* 5) Press "Import Namespace" button.
* 6) Check that new Namespace was successfully created.
* 7) Check that new Namespace is present in the table.
* 8) Check that values in table on page "Metadata Definitions" are
* the same as in Namespace JSON template and as in step (4):
*   - Name
*   - Public
*   - Protected
*   - Resource Types
* 9) Select Namespace in table and press "Delete Namespace" button.
* 10) In "Confirm Delete Namespace" window press "Delete Namespace".
* 11) Check that new Namespace was successfully deleted.
* 12) Check that new Namespace is not present in the table.'

def test_namespace_create_delete(self):

    namespaces_page = self.home_pg.go_to_system_metadatadefinitionspage()
    template_json_container = namespaces_page.json_load_template(namespace_template_name=self.NAMESPACE_TEMPLATE_PATH)
    namespace_name = template_json_container['display_name']
    namespace_res_type = template_json_container['resource_type_associations']
    namespace_res_type = [x['name'] for x in namespace_res_type]
    kwargs = {'namespace_name': namespace_name, 'page': namespaces_page, 'is_protected': False, 'template_json_container': template_json_container, 'template_path': self.NAMESPACE_TEMPLATE_PATH}
    self.namespace_create_with_checks(template_source_type='raw', is_public=True, expected_namespace_res=namespace_res_type, checks=(self.PUBLIC, self.PROTECTED), **kwargs)
    self.namespace_delete_with_checks(namespace_name, namespaces_page)
    self.namespace_create_with_checks(template_source_type='raw', is_public=False, expected_namespace_res=None, checks=(self.PUBLIC,), **kwargs)
    self.namespace_delete_with_checks(namespace_name, namespaces_page)
    self.namespace_create_with_checks(template_source_type='file', is_public=True, expected_namespace_res=namespace_res_type, checks=(self.PUBLIC, self.PROTECTED), **kwargs)
    self.namespace_delete_with_checks(namespace_name, namespaces_page)
    self.namespace_create_with_checks(template_source_type='file', is_public=False, expected_namespace_res=None, checks=(self.PUBLIC,), **kwargs)
    self.namespace_delete_with_checks(namespace_name, namespaces_page)
