How to use create_namespace method in lisa

Best Python code snippet using lisa_python

test_k8s_namespace.py

Source:test_k8s_namespace.py Github

copy

Full Screen

...35 K8sNamespace(config=config)36 def test_init_with_invalid_name(self):37 name = object()38 with self.assertRaises(SyntaxError):39 _utils.create_namespace(name=name)40 def test_init_with_name(self):41 name = "yoname"42 ns = _utils.create_namespace(name=name)43 self.assertIsNotNone(ns)44 self.assertIsInstance(ns, K8sNamespace)45 self.assertEqual("Namespace", ns.obj_type)46 self.assertEqual(ns.name, name)47 self.assertIsInstance(ns.config, K8sConfig)48 def test_init_with_name_and_config(self):49 nspace = "default"50 config = K8sConfig(kubeconfig=_utils.kubeconfig_fallback, namespace=nspace)51 name = "yoname"52 ns = _utils.create_namespace(config=config, name=name)53 self.assertIsNotNone(ns)54 self.assertIsInstance(ns, K8sNamespace)55 self.assertEqual(ns.name, name)56 self.assertEqual("Namespace", ns.obj_type)57 self.assertIsInstance(ns.config, K8sConfig)58 self.assertEqual(nspace, ns.config.namespace)59 # --------------------------------------------------------------------------------- struct60 def test_struct_k8s_namespace(self):61 name = "yoname"62 ns = _utils.create_namespace(name=name)63 self.assertIsInstance(ns, K8sNamespace)64 self.assertIsInstance(ns.base_url, str)65 self.assertIsInstance(ns.config, K8sConfig)66 self.assertIsInstance(ns.model, Namespace)67 self.assertIsInstance(ns.name, str)68 self.assertIsInstance(ns.obj_type, str)69 def test_struct_namespace(self):70 name = "yoname"71 ns = _utils.create_namespace(name=name)72 self.assertIsInstance(ns, K8sNamespace)73 self.assertIsInstance(ns.model, Namespace)74 self.assertIsInstance(ns.model.metadata, ObjectMeta)75 self.assertIsInstance(ns.model.spec, NamespaceSpec)76 self.assertIsInstance(ns.model.status, NamespaceStatus)77 # --------------------------------------------------------------------------------- add annotation78 def test_add_annotation_none_args(self):79 name = "yonamespace"80 ns = _utils.create_namespace(name=name)81 try:82 ns.add_annotation()83 self.fail("Should not fail.")84 except Exception as err:85 self.assertIsInstance(err, SyntaxError)86 def test_add_annotation_invalid_args(self):87 name = "yonamespace"88 ns = _utils.create_namespace(name=name)89 k = object()90 v = object()91 try:92 ns.add_annotation(k, v)93 self.fail("Should not fail.")94 except Exception as err:95 self.assertIsInstance(err, SyntaxError)96 def test_add_annotation(self):97 name = "yonamespace"98 ns = _utils.create_namespace(name=name)99 k = "yokey"100 v = "yovalue"101 ns.add_annotation(k, v)102 self.assertIn(k, ns.annotations)103 self.assertEqual(v, ns.annotations[k])104 # --------------------------------------------------------------------------------- add label105 def test_add_label_none_args(self):106 name = "yonamespace"107 ns = _utils.create_namespace(name=name)108 with self.assertRaises(SyntaxError):109 ns.add_label()110 def test_add_label_invalid_args(self):111 name = "yonamespace"112 ns = _utils.create_namespace(name=name)113 k = object()114 v = object()115 with self.assertRaises(SyntaxError):116 ns.add_label(k, v)117 def test_add_label(self):118 name = "yonamespace"119 ns = _utils.create_namespace(name=name)120 k = "yokey"121 v = "yovalue"122 ns.add_label(k, v)123 self.assertIn(k, ns.labels)124 self.assertEqual(v, ns.labels[k])125 # --------------------------------------------------------------------------------- get126 def test_get_nonexistent(self):127 name = "yonamespace"128 ns = _utils.create_namespace(name=name)129 if _utils.is_reachable(ns.config):130 with self.assertRaises(NotFoundException):131 ns.get()132 def test_get(self):133 name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))134 ns = _utils.create_namespace(name=name)135 if _utils.is_reachable(ns.config):136 ns.create()137 from_get = ns.get()138 self.assertIsInstance(from_get, K8sNamespace)139 self.assertEqual(ns, from_get)140 # --------------------------------------------------------------------------------- get annotation141 def test_get_annotation_none_arg(self):142 name = "yonamespace"143 ns = _utils.create_namespace(name=name)144 ann = ns.get_annotation()145 self.assertIsNone(ann)146 def test_get_annotation_invalid_arg(self):147 name = "yonamespace"148 svc = _utils.create_namespace(name=name)149 k = object()150 ann = svc.get_annotation(k)151 self.assertIsNone(ann)152 def test_get_annotation_doesnt_exist(self):153 name = "yonamespace"154 ns = _utils.create_namespace(name=name)155 k = "yokey"156 v = ns.get_annotation(k)157 self.assertIsNone(v)158 def test_get_annotation(self):159 name = "yonamespace"160 ns = _utils.create_namespace(name=name)161 k = "yokey"162 v_in = "yovalue"163 ns.add_annotation(k, v_in)164 v_out = ns.get_annotation(k)165 self.assertEqual(v_in, v_out)166 # --------------------------------------------------------------------------------- get annotations167 def test_get_annotations_doesnt_exist(self):168 name = "yonamespace"169 ns = _utils.create_namespace(name=name)170 self.assertEqual({}, ns.annotations)171 def test_get_annotations(self):172 name = "yonamespace"173 ns = _utils.create_namespace(name=name)174 count = 4175 for i in range(0, count):176 k = "yokey_{0}".format(i)177 v = "yovalue_{0}".format(i)178 ns.add_annotation(k, v)179 self.assertEqual(count, len(ns.annotations))180 for i in range(0, count):181 k = "yokey_{0}".format(i)182 v = "yovalue_{0}".format(i)183 self.assertIn(k, ns.annotations)184 self.assertEqual(v, ns.annotations[k])185 # --------------------------------------------------------------------------------- get label186 def test_get_label_none_arg(self):187 name = "yonamespace"188 ns = _utils.create_namespace(name=name)189 self.assertIsNone(ns.get_label())190 def test_get_label_invalid_arg(self):191 name = "yonamespace"192 ns = _utils.create_namespace(name=name)193 k = object()194 self.assertIsNone(ns.get_label(k))195 def test_get_label_doesnt_exist(self):196 name = "yonamespace"197 ns = _utils.create_namespace(name=name)198 k = "yokey"199 self.assertIsNone(ns.get_label(k))200 def test_get_label(self):201 name = "yonamespace"202 ns = _utils.create_namespace(name=name)203 k = "yokey"204 v = "yovalue"205 ns.add_label(k, v)206 self.assertEqual(v, ns.get_label(k))207 # --------------------------------------------------------------------------------- get labels208 def test_get_labels(self):209 name = "yonamespace"210 ns = _utils.create_namespace(name=name)211 labels = {"yokey": "yovalue"}212 ns.labels = labels213 self.assertEqual(labels, ns.labels)214 # --------------------------------------------------------------------------------- set annotations215 def test_set_annotations_none_arg(self):216 name = "yonamespace"217 ns = _utils.create_namespace(name=name)218 with self.assertRaises(SyntaxError):219 ns.annotations = None220 def test_set_annotations_invalid_arg(self):221 name = "yonamespace"222 ns = _utils.create_namespace(name=name)223 labels = object()224 with self.assertRaises(SyntaxError):225 ns.annotations = labels226 def test_set_annotations_str_int(self):227 name = "yonamespace"228 ns = _utils.create_namespace(name=name)229 labels = {"yokey": 1234}230 ns.annotations = labels231 self.assertEqual(ns.annotations, labels)232 def test_set_annotations(self):233 name = "yonamespace"234 ns = _utils.create_namespace(name=name)235 anns = {"yokey": "yovalue"}236 ns.annotations = anns237 self.assertEqual(anns, ns.annotations)238 # --------------------------------------------------------------------------------- set labels239 def test_set_labels_none_arg(self):240 name = "yonamespace"241 ns = _utils.create_namespace(name=name)242 with self.assertRaises(SyntaxError):243 ns.labels = None244 def test_set_labels_invalid_arg(self):245 name = "yonamespace"246 ns = _utils.create_namespace(name=name)247 labels = object()248 with self.assertRaises(SyntaxError):249 ns.labels = labels250 def test_set_labels_invalid_dict(self):251 name = "yonamespace"252 ns = _utils.create_namespace(name=name)253 labels = {"yokey": 1234}254 with self.assertRaises(SyntaxError):255 ns.labels = labels256 def test_set_labels(self):257 name = "yonamespace"258 ns = _utils.create_namespace(name=name)259 labels = {"yokey": "yovalue"}260 ns.labels = labels261 self.assertEqual(labels, ns.labels)262 # --------------------------------------------------------------------------------- api - get by name263 # def test_get_by_name_nonexistent(self):264 # name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))265 # ns = utils.create_namespace(name=name)266 # if utils.is_reachable(ns.config):267 # _list = K8sNamespace.get_by_name(config=ns.config, name=name)268 # self.assertIsInstance(_list, list)269 # self.assertEqual(0, len(_list))270 #271 # def test_get_by_name(self):272 # name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))273 # ns = utils.create_namespace(name=name)274 # if utils.is_reachable(ns.config):275 # ns.create()276 # _list = K8sNamespace.get_by_name(config=ns.config, name=name)277 # self.assertIsInstance(_list, list)278 # self.assertEqual(1, len(_list))279 # from_get = _list[0]280 # self.assertIsInstance(from_get, K8sNamespace)281 # self.assertEqual(from_get, ns)282 # --------------------------------------------------------------------------------- api - list283 def test_list_without_create(self):284 name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))285 ns = _utils.create_namespace(name=name)286 if _utils.is_reachable(ns.config):287 _list = ns.list()288 for x in _list:289 self.assertIsInstance(x, K8sNamespace)290 self.assertIsInstance(_list, list)291 def test_list(self):292 name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))293 ns = _utils.create_namespace(name=name)294 if _utils.is_reachable(ns.config):295 ns.create()296 _list = ns.list()297 for x in _list:298 self.assertIsInstance(x, K8sNamespace)299 self.assertIsInstance(_list, list)300 # --------------------------------------------------------------------------------- api - create301 def test_create(self):302 name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))303 ns = _utils.create_namespace(name=name)304 if _utils.is_reachable(ns.config):305 ns.create()306 from_get = ns.get()307 self.assertEqual(ns, from_get)308 def test_create_already_exists(self):309 name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))310 ns = _utils.create_namespace(name=name)311 if _utils.is_reachable(ns.config):312 ns.create()313 with self.assertRaises(AlreadyExistsException):314 ns.create()315 # --------------------------------------------------------------------------------- api - update316 def test_update_nonexistent(self):317 name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))318 ns = _utils.create_namespace(name=name)319 if _utils.is_reachable(ns.config):320 with self.assertRaises(NotFoundException):321 ns.update()322 # --------------------------------------------------------------------------------- api - delete323 def test_delete_nonexistent(self):324 name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))325 ns = _utils.create_namespace(name=name)326 if _utils.is_reachable(ns.config):327 with self.assertRaises(NotFoundException):328 ns.delete()329 def test_delete(self):330 name = "yo-{0}".format(str(uuid.uuid4().hex[:16]))331 ns = _utils.create_namespace(name=name)332 if _utils.is_reachable(ns.config):333 ns.create()334 from_get = K8sNamespace.get_by_name(ns.config, ns.name)335 self.assertIsInstance(from_get, K8sNamespace)336 self.assertEqual(name, from_get.name)337 ns.delete()338 from_get = K8sNamespace.get_by_name(ns.config, ns.name)...

Full Screen

Full Screen

test_k8s.py

Source:test_k8s.py Github

copy

Full Screen

...31class TestK8s(object):32 def test_pod(self):33 api_key = get_oc_api_token()34 with K8sBackend(api_key=api_key) as k8s_backend:35 namespace = k8s_backend.create_namespace()36 with DockerBackend() as backend:37 image = backend.ImageClass("openshift/hello-openshift")38 pod = image.run_in_pod(namespace=namespace)39 try:40 pod.wait(200)41 assert pod.is_ready()42 assert pod.get_phase() == PodPhase.RUNNING43 finally:44 pod.delete()45 assert pod.get_phase() == PodPhase.TERMINATING46 k8s_backend.delete_namespace(namespace)47 def test_pod_from_template(self):48 template = {49 "apiVersion": "v1",50 "kind": "Pod",51 "metadata": {52 "name": "myapp-pod",53 "labels": {54 "app": "myapp"55 }56 },57 "spec": {58 "containers": [59 {60 "name": "myapp-container",61 "image": "busybox",62 "command": [63 "sh",64 "-c",65 "echo Hello Kubernetes! && sleep 3600"66 ]67 }68 ]69 }70 }71 api_key = get_oc_api_token()72 with K8sBackend(api_key=api_key) as k8s_backend:73 namespace = k8s_backend.create_namespace()74 pod = Pod(namespace=namespace, from_template=template)75 try:76 pod.wait(200)77 assert pod.is_ready()78 assert pod.get_phase() == PodPhase.RUNNING79 finally:80 pod.delete()81 assert pod.get_phase() == PodPhase.TERMINATING82 k8s_backend.delete_namespace(namespace)83 def test_database_deployment(self):84 api_key = get_oc_api_token()85 with K8sBackend(api_key=api_key) as k8s_backend:86 namespace = k8s_backend.create_namespace()87 with DockerBackend() as backend:88 postgres_image = backend.ImageClass("centos/postgresql-10-centos7")89 postgres_image_metadata = postgres_image.get_metadata()90 # set up env variables91 db_env_variables = {"POSTGRESQL_USER": "user",92 "POSTGRESQL_PASSWORD": "pass",93 "POSTGRESQL_DATABASE": "db"}94 postgres_image_metadata.env_variables.update(db_env_variables)95 db_labels = {"app": "postgres"}96 db_service = Service(name="database", ports=["5432"], selector=db_labels,97 namespace=namespace,98 create_in_cluster=True)99 db_deployment = Deployment(name="database", selector=db_labels, labels=db_labels,100 image_metadata=postgres_image_metadata,101 namespace=namespace,102 create_in_cluster=True)103 try:104 db_deployment.wait(200)105 assert db_deployment.all_pods_ready()106 finally:107 db_deployment.delete()108 db_service.delete()109 k8s_backend.delete_namespace(namespace)110 def test_list_pods(self):111 api_key = get_oc_api_token()112 with K8sBackend(api_key=api_key) as k8s_backend:113 namespace = k8s_backend.create_namespace()114 with DockerBackend() as backend:115 image = backend.ImageClass("openshift/hello-openshift")116 pod = image.run_in_pod(namespace=namespace)117 try:118 pod.wait(200)119 assert any(pod.name == p.name for p in k8s_backend.list_pods())120 finally:121 pod.delete()122 k8s_backend.delete_namespace(namespace)123 def test_list_services(self):124 api_key = get_oc_api_token()125 with K8sBackend(api_key=api_key) as k8s_backend:126 namespace = k8s_backend.create_namespace()127 labels = {"app": "postgres"}128 service = Service(name="database", ports=["5432"], selector=labels, namespace=namespace,129 create_in_cluster=True)130 try:131 assert any(service.name == s.name for s in k8s_backend.list_services())132 finally:133 service.delete()134 k8s_backend.delete_namespace(namespace)135 def test_list_deployments(self):136 api_key = get_oc_api_token()137 with K8sBackend(api_key=api_key) as k8s_backend:138 namespace = k8s_backend.create_namespace()139 with DockerBackend() as backend:140 postgres_image = backend.ImageClass("centos/postgresql-10-centos7")141 postgres_image_metadata = postgres_image.get_metadata()142 # set up env variables143 db_env_variables = {"POSTGRESQL_USER": "user",144 "POSTGRESQL_PASSWORD": "pass",145 "POSTGRESQL_DATABASE": "db"}146 postgres_image_metadata.env_variables.update(db_env_variables)147 db_labels = {"app": "postgres"}148 db_deployment = Deployment(name="database", selector=db_labels, labels=db_labels,149 image_metadata=postgres_image_metadata,150 namespace=namespace,151 create_in_cluster=True)152 try:153 db_deployment.wait(200)154 assert db_deployment.all_pods_ready()155 assert any(db_deployment.name == d.name for d in k8s_backend.list_deployments())156 finally:157 db_deployment.delete()158 k8s_backend.delete_namespace(namespace)159 def test_list_pod_for_namespace(self):160 api_key = get_oc_api_token()161 with K8sBackend(api_key=api_key) as k8s_backend:162 namespace1 = k8s_backend.create_namespace()163 namespace2 = k8s_backend.create_namespace()164 with DockerBackend() as backend:165 image = backend.ImageClass("openshift/hello-openshift")166 pod1 = image.run_in_pod(namespace=namespace1)167 try:168 pod1.wait(200)169 assert any(pod1.name == p.name for p in k8s_backend.list_pods(namespace1))170 assert not any(pod1.name == p.name for p in k8s_backend.list_pods(namespace2))171 finally:172 pod1.delete()173 k8s_backend.delete_namespace(namespace1)174 k8s_backend.delete_namespace(namespace2)175 def test_deployment_from_template(self):176 api_key = get_oc_api_token()177 with K8sBackend(api_key=api_key) as k8s_backend:178 namespace = k8s_backend.create_namespace()179 template = """180 apiVersion: apps/v1181 kind: Deployment182 metadata:183 name: hello-world184 labels:185 app: hello-world186 spec:187 replicas: 3188 selector:189 matchLabels:190 app: hello-world191 template:192 metadata:193 labels:194 app: hello-world195 spec:196 containers:197 - name: hello-openshift198 image: openshift/hello-openshift199 """200 test_deployment = Deployment(namespace=namespace, from_template=template,201 create_in_cluster=True)202 try:203 test_deployment.wait(200)204 assert test_deployment.all_pods_ready()205 finally:206 test_deployment.delete()207 k8s_backend.delete_namespace(namespace)208 def test_cleanup(self):209 api = get_core_api()210 # take just namespaces that are not in terminating state211 number_of_namespaces = len(212 [item for item in api.list_namespace().items if item.status.phase != "Terminating"])213 api_key = get_oc_api_token()214 with K8sBackend(api_key=api_key, cleanup=[K8sCleanupPolicy.NAMESPACES]) as k8s_backend:215 # create two namespaces216 k8s_backend.create_namespace()217 k8s_backend.create_namespace()218 # cleanup should delete two namespaces created with k8s backend219 assert len(220 [item for item in api.list_namespace().items221 if item.status.phase != "Terminating"]) == number_of_namespaces222 with K8sBackend(api_key=api_key) as k8s_backend:223 # create two namespaces224 k8s_backend.create_namespace()225 k8s_backend.create_namespace()226 # no cleanup - namespaces are not deleted after work with backend is finished227 assert len(228 [item for item in api.list_namespace().items...

Full Screen

Full Screen

test_namespace.py

Source:test_namespace.py Github

copy

Full Screen

...3import flottitools.utils.namespaceutils as namespaceutils4class TestMoveNodesToNamespace(mayatest.MayaTestCase):5 def test_move_one_node(self):6 pm.namespace(set=':')7 ns = self.create_namespace(':foo:bar')8 test_cube = self.create_cube()9 self.assertEqual('', test_cube.namespace())10 namespaceutils.move_node_to_namespace(test_cube, ns)11 self.assertEqual(ns, test_cube.parentNamespace())12 def test_move_multiple_nodes(self):13 pm.namespace(set=':')14 test_cubes = [self.create_cube() for _ in range(5)]15 ns = self.create_namespace(':foo:bar')16 [self.assertEqual('', x.namespace()) for x in test_cubes]17 namespaceutils.move_nodes_to_namespace(test_cubes, ns)18 [self.assertEqual(ns, x.parentNamespace()) for x in test_cubes]19class TestPreserveNamespace(mayatest.MayaTestCase):20 def test_return_to_root(self):21 pm.namespace(set=':')22 ns = self.create_namespace(':foo')23 with namespaceutils.preserve_namespace():24 pm.namespace(set=':foo')25 test_cube = self.create_cube()26 self.assertEqual(ns, test_cube.parentNamespace())27 self.assertEqual(':', self.pm.namespaceInfo(currentNamespace=True))28 def test_return_to_not_root(self):29 pm.namespace(set=':')30 ns = self.create_namespace(':foo')31 ns2 = self.create_namespace(':bar')32 pm.namespace(set=ns2)33 with namespaceutils.preserve_namespace(ns):34 test_cube = self.create_cube()35 self.assertEqual(ns, test_cube.parentNamespace())36 self.assertEqual(ns2, self.pm.namespaceInfo(currentNamespace=True))37 def test_same_ns_as_current(self):38 pm.namespace(set=':')39 ns = self.create_namespace(':foo')40 pm.namespace(set=ns)41 with namespaceutils.preserve_namespace(ns):42 test_cube = self.create_cube()43 self.assertEqual(ns, test_cube.parentNamespace())44 self.assertEqual(ns, self.pm.namespaceInfo(currentNamespace=True))45class TestSetNamespace(mayatest.MayaTestCase):46 def test_set_from_root_with_colon_prefix(self):47 pm.namespace(set=':')48 ns = self.create_namespace(':foo')49 namespaceutils.set_namespace(':foo')50 current_ns = pm.namespaceInfo(currentNamespace=True)51 self.assertEqual(ns, current_ns)52 def test_set_from_root_without_colon_prefix(self):53 pm.namespace(set=':')54 ns = self.create_namespace(':foo')55 namespaceutils.set_namespace('foo')56 current_ns = pm.namespaceInfo(currentNamespace=True)57 self.assertEqual(ns, current_ns)58 def test_searches_all_namespaces_if_ns_not_in_current(self):59 pm.namespace(set=':')60 ns = self.create_namespace(':foo')61 ns2 = self.create_namespace(':bar')62 pm.namespace(set=ns2)63 namespaceutils.set_namespace('foo')64 current_ns = pm.namespaceInfo(currentNamespace=True)65 self.assertEqual(ns, current_ns)66 def test_if_multiple_matching_ns_take_first_nested_first(self):67 pm.namespace(set=':')68 ns_foo = self.create_namespace(':foo')69 ns_bar = self.create_namespace(':bar')70 ns_bar_foo = self.create_namespace(':bar:foo')71 ns_bar_foo_spam_foo = self.create_namespace(':bar:foo:spam:foo')72 pm.namespace(set=ns_bar)73 namespaceutils.set_namespace('foo')74 current_ns = pm.namespaceInfo(currentNamespace=True)75 self.assertEqual(ns_bar_foo, current_ns)76 def test_start_at_root_true(self):77 pm.namespace(set=':')78 ns_foo = self.create_namespace(':foo')79 ns_bar = self.create_namespace(':bar')80 ns_bar_foo = self.create_namespace(':bar:foo')81 ns_bar_foo_spam_foo = self.create_namespace(':bar:foo:spam:foo')82 pm.namespace(set=ns_bar)83 namespaceutils.set_namespace('foo', start_at_root=True)84 current_ns = pm.namespaceInfo(currentNamespace=True)85 self.assertEqual(ns_foo, current_ns)86class TestAddNamespaceToRoot(mayatest.MayaTestCase):87 def test_root_current_namespace(self):88 pm.namespace(set=':')89 ns = namespaceutils.add_namespace_to_root('foo')90 expected = [ns]91 result = pm.listNamespaces(recursive=True)92 self.assertListEqual(expected, result)93 def test_not_root_and_no_leading_colon(self):94 pm.namespace(set=':')95 ns_bar = self.create_namespace('bar')96 pm.namespace(set=':bar')97 ns = namespaceutils.add_namespace_to_root('foo')98 expected = [':bar', ':foo']99 result = [str(x) for x in pm.listNamespaces(recursive=True)]100 self.assertListEqual(expected, result)101 def test_not_root_with_leading_colon(self):102 pm.namespace(set=':')103 ns_bar = self.create_namespace('bar')104 pm.namespace(set=':bar')105 ns = namespaceutils.add_namespace_to_root(':foo')106 expected = [':bar', ':foo']107 result = [str(x) for x in pm.listNamespaces(recursive=True)]108 self.assertListEqual(expected, result)109 def test_noop_if_namespace_already_exists(self):110 pm.namespace(set=':')111 ns_foo = self.create_namespace('foo')112 namespaceutils.add_namespace_to_root('foo')113 expected = [ns_foo]114 result = pm.listNamespaces(recursive=True)115 self.assertListEqual(expected, result)116class TestDuplicateToNamespace(mayatest.MayaTestCase):117 def test_basic(self):118 test_cube = self.create_cube()119 dups = namespaceutils.duplicate_to_namespace([test_cube])120 self.assertEqual(len(dups), 1)121 result = dups[0].nodeName()122 expected = 'pCube' + str(int(test_cube.nodeName().split('pCube')[1])+1)123 self.assertEqual(expected, result)124 def test_dup_to_namespace(self):125 test_cube = self.create_cube()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful