summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerg Melikyan <smelikyan@mirantis.com>2013-06-10 17:09:49 +0400
committerSerg Melikyan <smelikyan@mirantis.com>2013-06-10 17:15:12 +0400
commitbe1bcaf241825477f27faa9f8ac646b02a451fa5 (patch)
tree6003875877a3745c37f04d02926d66d596ed1fa5
parent2549bd7f475257229474d3ef1d466adeea1e21a6 (diff)
Added tests for new services0.1release-0.1
Notes
Notes (review): Verified+2: Jenkins Approved+1: Timur <tnurlygayanov@mirantis.com> Code-Review+2: Timur <tnurlygayanov@mirantis.com> Submitted-by: Jenkins Submitted-at: Mon, 10 Jun 2013 16:55:53 +0000 Reviewed-on: https://review.openstack.org/32390 Project: stackforge/python-muranoclient Branch: refs/heads/release-0.1
-rw-r--r--tests/muranoclient/test_client_with_fake_http.py262
-rw-r--r--tests/muranoclient/test_methods.py330
2 files changed, 592 insertions, 0 deletions
diff --git a/tests/muranoclient/test_client_with_fake_http.py b/tests/muranoclient/test_client_with_fake_http.py
index e8d2b3f..64f1179 100644
--- a/tests/muranoclient/test_client_with_fake_http.py
+++ b/tests/muranoclient/test_client_with_fake_http.py
@@ -204,3 +204,265 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase):
204 204
205 result = test_client.webServers.list('1', 'test') 205 result = test_client.webServers.list('1', 'test')
206 assert result == [] 206 assert result == []
207
208 @httprettified
209 def test_client_aspapp_list(self):
210 body = '''
211{
212 "aspNetApps":
213 [
214 {
215 "id": "88f6ed99ff3645bcb84e1e37ab9ece3d",
216 "name": "frontend",
217 "created": "2010-11-30T03:23:42Z",
218 "updated": "2010-11-30T03:23:44Z",
219 "domain": "ACME",
220 "repository": "https://github.com/Mirantis/murano-mvc-demo.git",
221 "uri": "http://10.0.0.2",
222 "units": [{
223 "id": "59255829f0574297acc1cd3a18ff6fd7",
224 "address": "10.0.0.2",
225 "location": "west-dc"
226 }]
227 }, {
228 "id": "aa49dcaff9914b8abb26855f0799b0e0",
229 "name": "backend",
230 "created": "2010-11-30T03:23:42Z",
231 "updated": "2010-11-30T03:23:44Z",
232 "repository": "https://github.com/Mirantis/murano-mvc-demo.git",
233 "uri": "http://10.0.0.3",
234 "domain": "ACME2" ,
235 "units": [{
236 "id": "274b54f6bbe6493690e7107aa947e112",
237 "address": "10.0.0.3",
238 "location": "west-dc"
239 }]
240 }
241 ]
242}
243'''
244 url = 'http://no-resolved-host:8001/environments' \
245 '/1/aspNetApps'
246 HTTPretty.register_uri(HTTPretty.GET, url,
247 body=body,
248 adding_headers={
249 'Content-Type': 'application/json', })
250 endpoint = 'http://no-resolved-host:8001'
251 test_client = Client('1', endpoint=endpoint, token='1', timeout=10)
252
253 result = test_client.aspNetApps.list('1', 'test')
254 assert result[0].name == 'frontend'
255
256 @httprettified
257 def test_client_aspapp_create(self):
258 body = '''
259{
260 "id": "88f6ed99ff3645bcb84e1e37ab9ece3d",
261 "name": "frontend",
262 "created": "2010-11-30T03:23:42Z",
263 "updated": "2010-11-30T03:23:44Z",
264 "domain": "ACME",
265 "repository": "https://github.com/Mirantis/murano-mvc-demo.git",
266 "uri": "http://10.0.0.2",
267 "units": [{
268 "id": "59255829f0574297acc1cd3a18ff6fd7",
269 "address": "10.0.0.2",
270 "location": "west-dc"
271 }]
272}
273'''
274 url = 'http://no-resolved-host:8001/environments' \
275 '/1/aspNetApps'
276 HTTPretty.register_uri(HTTPretty.POST, url,
277 body=body,
278 adding_headers={
279 'Content-Type': 'application/json', })
280 endpoint = 'http://no-resolved-host:8001'
281 test_client = Client('1', endpoint=endpoint, token='1', timeout=10)
282
283 result = test_client.aspNetApps.create('1', 'test', 'test')
284 assert result.name == 'frontend'
285
286 @httprettified
287 def test_client_aspapp_list_without_elements(self):
288 body = '{"aspNetApps": []}'
289 url = 'http://no-resolved-host:8001/environments' \
290 '/1/aspNetApps'
291 HTTPretty.register_uri(HTTPretty.GET, url,
292 body=body,
293 adding_headers={
294 'Content-Type': 'application/json', })
295 endpoint = 'http://no-resolved-host:8001'
296 test_client = Client('1', endpoint=endpoint, token='1', timeout=10)
297
298 result = test_client.aspNetApps.list('1', 'test')
299 assert result == []
300
301 @httprettified
302 def test_client_webfarm_list(self):
303 body = '''
304{
305 "webServerFarms":
306 [
307 {
308 "id": "01fa4412ab4849acb27394aaf307ca88",
309 "name": "frontend",
310 "created": "2010-11-30T03:23:42Z",
311 "updated": "2010-11-30T03:23:44Z",
312 "domain": "ACME",
313 "loadBalancerPort": 80,
314 "uri": "http://192.168.1.1:80",
315 "units":
316 [
317 {
318 "id": "a34992c8634b482798187d3c0e1c999a",
319 "address": "10.0.0.2",
320 "location": "west-dc"
321 },
322 {
323 "id": "fcd60488bb6f4acf97ccdb8f8fc6bc9a",
324 "address": "10.0.0.3",
325 "location": "west-dc"
326 }
327 ]
328 }
329 ]
330}
331'''
332 url = 'http://no-resolved-host:8001/environments' \
333 '/1/webServerFarms'
334 HTTPretty.register_uri(HTTPretty.GET, url,
335 body=body,
336 adding_headers={
337 'Content-Type': 'application/json', })
338 endpoint = 'http://no-resolved-host:8001'
339 test_client = Client('1', endpoint=endpoint, token='1', timeout=10)
340
341 result = test_client.webServerFarms.list('1', 'test')
342 assert result[0].name == 'frontend'
343
344 @httprettified
345 def test_client_webfarm_create(self):
346 body = '''
347{
348 "name": "frontend",
349 "domain": "ACME",
350 "loadBalancerPort": 80,
351 "uri": "http://192.168.1.1:80",
352 "units":
353 [
354 {"location": "west-dc"},
355 {"location": "west-dc"}
356 ]
357}
358'''
359 url = 'http://no-resolved-host:8001/environments' \
360 '/1/webServerFarms'
361 HTTPretty.register_uri(HTTPretty.POST, url,
362 body=body,
363 adding_headers={
364 'Content-Type': 'application/json', })
365 endpoint = 'http://no-resolved-host:8001'
366 test_client = Client('1', endpoint=endpoint, token='1', timeout=10)
367
368 result = test_client.webServerFarms.create('1', 'test', 'test')
369 assert result.name == 'frontend'
370
371 @httprettified
372 def test_client_webfarm_list_without_elements(self):
373 body = '{"webServerFarms": []}'
374 url = 'http://no-resolved-host:8001/environments' \
375 '/1/webServerFarms'
376 HTTPretty.register_uri(HTTPretty.GET, url,
377 body=body,
378 adding_headers={
379 'Content-Type': 'application/json', })
380 endpoint = 'http://no-resolved-host:8001'
381 test_client = Client('1', endpoint=endpoint, token='1', timeout=10)
382
383 result = test_client.webServerFarms.list('1', 'test')
384 assert result == []
385
386 @httprettified
387 def test_client_aspappfarm_list(self):
388 body = '''
389{
390 "aspNetAppFarms":
391 [
392 {
393 "id": "01fa4412ab4849acb27394aaf307ca88",
394 "name": "frontend",
395 "created": "2010-11-30T03:23:42Z",
396 "updated": "2010-11-30T03:23:44Z",
397 "domain": "ACME",
398 "loadBalancerPort": 80,
399 "uri": "http://192.168.1.1:80",
400 "units":
401 [
402 {
403 "id": "3374f4eb850e4b27bf734649d7004cc0",
404 "address": "10.0.0.2",
405 "location": "west-dc"
406 },
407 {
408 "id": "fcd60488bb6f4acf97ccdb8f8fc6bc9a",
409 "address": "10.0.0.3",
410 "location": "west-dc"
411 }
412 ]
413 }
414 ]
415}
416'''
417 url = 'http://no-resolved-host:8001/environments' \
418 '/1/aspNetAppFarms'
419 HTTPretty.register_uri(HTTPretty.GET, url,
420 body=body,
421 adding_headers={
422 'Content-Type': 'application/json', })
423 endpoint = 'http://no-resolved-host:8001'
424 test_client = Client('1', endpoint=endpoint, token='1', timeout=10)
425
426 result = test_client.aspNetAppFarms.list('1', 'test')
427 assert result[0].name == 'frontend'
428
429 @httprettified
430 def test_client_aspappfarm_create(self):
431 body = '''
432{
433 "name": "frontend",
434 "adminPassword": "password",
435 "domain": "acme.dc",
436 "loadBalancerPort": 80,
437 "repository": "https://github.com/Mirantis/murano-mvc-demo.git",
438 "units": [{
439 "location": "west-dc"
440 }]
441}
442'''
443 url = 'http://no-resolved-host:8001/environments' \
444 '/1/aspNetAppFarms'
445 HTTPretty.register_uri(HTTPretty.POST, url,
446 body=body,
447 adding_headers={
448 'Content-Type': 'application/json', })
449 endpoint = 'http://no-resolved-host:8001'
450 test_client = Client('1', endpoint=endpoint, token='1', timeout=10)
451
452 result = test_client.aspNetAppFarms.create('1', 'test', 'test')
453 assert result.name == 'frontend'
454
455 @httprettified
456 def test_client_aspappfarm_list_without_elements(self):
457 body = '{"aspNetAppFarms": []}'
458 url = 'http://no-resolved-host:8001/environments' \
459 '/1/aspNetAppFarms'
460 HTTPretty.register_uri(HTTPretty.GET, url,
461 body=body,
462 adding_headers={
463 'Content-Type': 'application/json', })
464 endpoint = 'http://no-resolved-host:8001'
465 test_client = Client('1', endpoint=endpoint, token='1', timeout=10)
466
467 result = test_client.aspNetAppFarms.list('1', 'test')
468 assert result == []
diff --git a/tests/muranoclient/test_methods.py b/tests/muranoclient/test_methods.py
index fe1c0c3..32bdd56 100644
--- a/tests/muranoclient/test_methods.py
+++ b/tests/muranoclient/test_methods.py
@@ -40,6 +40,9 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase):
40 assert test_client.sessions is not None 40 assert test_client.sessions is not None
41 assert test_client.activeDirectories is not None 41 assert test_client.activeDirectories is not None
42 assert test_client.webServers is not None 42 assert test_client.webServers is not None
43 assert test_client.aspNetApps is not None
44 assert test_client.webServerFarms is not None
45 assert test_client.aspNetAppFarms is not None
43 46
44 def test_env_manager_list(self): 47 def test_env_manager_list(self):
45 manager = environments.EnvironmentManager(api) 48 manager = environments.EnvironmentManager(api)
@@ -461,3 +464,330 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase):
461 except TypeError: 464 except TypeError:
462 pass 465 pass
463 assert result == 'Exception' 466 assert result == 'Exception'
467
468 def test_webfarm_list_with_one_parameter(self):
469 manager = services.WebServerFarmManager(api)
470 result = manager.list('datacenter1')
471 assert result == []
472
473 def test_webfarm_list_with_all_parameters(self):
474 manager = services.WebServerFarmManager(api)
475 result = manager.list('test', '1')
476 assert result == []
477
478 def test_webfarm_list_with_named_parameters(self):
479 manager = services.WebServerFarmManager(api)
480 result = manager.list(environment_id='test', session_id='1')
481 assert result == []
482
483 def test_webfarm_list_with_named_parameter(self):
484 manager = services.WebServerFarmManager(api)
485 result = manager.list(environment_id='test')
486 assert result == []
487
488 def test_webfarm_list_negative_without_parameters(self):
489 result = 'Exception'
490 manager = services.WebServerFarmManager(api)
491 try:
492 result = manager.list()
493 except TypeError:
494 pass
495 assert result is 'Exception'
496
497 def test_webfarm_create(self):
498 manager = services.WebServerFarmManager(api)
499 result = manager.create('datacenter1', 'session1', 'test')
500 assert result.headers == {'X-Configuration-Session': 'session1'}
501 assert result.body == 'test'
502
503 def test_webfarm_create_with_named_parameters(self):
504 manager = services.WebServerFarmManager(api)
505 result = manager.create(environment_id='datacenter1',
506 session_id='session2',
507 web_server_farm='test2')
508 assert result.headers == {'X-Configuration-Session': 'session2'}
509 assert result.body == 'test2'
510
511 def test_webfarm_create_negative_with_two_parameters(self):
512 result = 'Exception'
513 manager = services.WebServerFarmManager(api)
514 try:
515 result = manager.create('datacenter1', 'session1')
516 except TypeError:
517 pass
518 assert result is 'Exception'
519
520 def test_webfarm_create_negative_with_one_parameter(self):
521 result = 'Exception'
522 manager = services.WebServerFarmManager(api)
523 try:
524 result = manager.create('datacenter1')
525 except TypeError:
526 pass
527 assert result is 'Exception'
528
529 def test_webfarm_create_negative_without_parameters(self):
530 result = 'Exception'
531 manager = services.WebServerFarmManager(api)
532 try:
533 result = manager.create()
534 except TypeError:
535 pass
536 assert result is 'Exception'
537
538 def test_webfarm_delete(self):
539 manager = services.WebServerFarmManager(api)
540 result = manager.delete('datacenter1', 'session1', 'test')
541 assert result is None
542
543 def test_webfarm_delete_with_named_parameters(self):
544 manager = services.WebServerFarmManager(api)
545 result = manager.delete(environment_id='datacenter1',
546 session_id='session1',
547 service_id='test')
548 assert result is None
549
550 def test_webfarm_delete_negative_with_two_parameters(self):
551 result = 'Exception'
552 manager = services.WebServerFarmManager(api)
553 try:
554 result = manager.delete('datacenter1', 'session1')
555 except TypeError:
556 pass
557 assert result == 'Exception'
558
559 def test_webfarm_delete_negative_with_one_parameter(self):
560 result = 'Exception'
561 manager = services.WebServerFarmManager(api)
562 try:
563 result = manager.delete('datacenter1')
564 except TypeError:
565 pass
566 assert result == 'Exception'
567
568 def test_webfarm_delete_negative_without_parameters(self):
569 result = 'Exception'
570 manager = services.WebServerFarmManager(api)
571 try:
572 result = manager.delete()
573 except TypeError:
574 pass
575 assert result == 'Exception'
576
577 def test_aspnetapp_list_with_one_parameter(self):
578 manager = services.AspNetAppManager(api)
579 result = manager.list('datacenter1')
580 assert result == []
581
582 def test_aspnetapp_list_with_all_parameters(self):
583 manager = services.AspNetAppManager(api)
584 result = manager.list('test', '1')
585 assert result == []
586
587 def test_aspnetapp_list_with_named_parameters(self):
588 manager = services.AspNetAppManager(api)
589 result = manager.list(environment_id='test', session_id='1')
590 assert result == []
591
592 def test_aspnetapp_list_with_named_parameter(self):
593 manager = services.AspNetAppManager(api)
594 result = manager.list(environment_id='test')
595 assert result == []
596
597 def test_aspnetapp_list_negative_without_parameters(self):
598 result = 'Exception'
599 manager = services.AspNetAppManager(api)
600 try:
601 result = manager.list()
602 except TypeError:
603 pass
604 assert result is 'Exception'
605
606 def test_aspnetapp_create(self):
607 manager = services.AspNetAppManager(api)
608 result = manager.create('datacenter1', 'session1', 'test')
609 assert result.headers == {'X-Configuration-Session': 'session1'}
610 assert result.body == 'test'
611
612 def test_aspnetapp_create_with_named_parameters(self):
613 manager = services.AspNetAppManager(api)
614 result = manager.create(environment_id='datacenter1',
615 session_id='session2',
616 app='test2')
617 assert result.headers == {'X-Configuration-Session': 'session2'}
618 assert result.body == 'test2'
619
620 def test_aspnetapp_create_negative_with_two_parameters(self):
621 result = 'Exception'
622 manager = services.AspNetAppManager(api)
623 try:
624 result = manager.create('datacenter1', 'session1')
625 except TypeError:
626 pass
627 assert result is 'Exception'
628
629 def test_aspnetapp_create_negative_with_one_parameter(self):
630 result = 'Exception'
631 manager = services.AspNetAppManager(api)
632 try:
633 result = manager.create('datacenter1')
634 except TypeError:
635 pass
636 assert result is 'Exception'
637
638 def test_aspnetapp_create_negative_without_parameters(self):
639 result = 'Exception'
640 manager = services.AspNetAppManager(api)
641 try:
642 result = manager.create()
643 except TypeError:
644 pass
645 assert result is 'Exception'
646
647 def test_aspnetapp_delete(self):
648 manager = services.AspNetAppManager(api)
649 result = manager.delete('datacenter1', 'session1', 'test')
650 assert result is None
651
652 def test_aspnetapp_delete_with_named_parameters(self):
653 manager = services.AspNetAppManager(api)
654 result = manager.delete(environment_id='datacenter1',
655 session_id='session1',
656 service_id='test')
657 assert result is None
658
659 def test_aspnetapp_delete_negative_with_two_parameters(self):
660 result = 'Exception'
661 manager = services.AspNetAppManager(api)
662 try:
663 result = manager.delete('datacenter1', 'session1')
664 except TypeError:
665 pass
666 assert result == 'Exception'
667
668 def test_aspnetapp_delete_negative_with_one_parameter(self):
669 result = 'Exception'
670 manager = services.AspNetAppManager(api)
671 try:
672 result = manager.delete('datacenter1')
673 except TypeError:
674 pass
675 assert result == 'Exception'
676
677 def test_aspnetapp_delete_negative_without_parameters(self):
678 result = 'Exception'
679 manager = services.AspNetAppManager(api)
680 try:
681 result = manager.delete()
682 except TypeError:
683 pass
684 assert result == 'Exception'
685
686 def test_aspnetfarm_list_with_one_parameter(self):
687 manager = services.AspNetAppFarmManager(api)
688 result = manager.list('datacenter1')
689 assert result == []
690
691 def test_aspnetfarm_list_with_all_parameters(self):
692 manager = services.AspNetAppFarmManager(api)
693 result = manager.list('test', '1')
694 assert result == []
695
696 def test_aspnetfarm_list_with_named_parameters(self):
697 manager = services.AspNetAppFarmManager(api)
698 result = manager.list(environment_id='test', session_id='1')
699 assert result == []
700
701 def test_aspnetfarm_list_with_named_parameter(self):
702 manager = services.AspNetAppFarmManager(api)
703 result = manager.list(environment_id='test')
704 assert result == []
705
706 def test_aspnetfarm_list_negative_without_parameters(self):
707 result = 'Exception'
708 manager = services.AspNetAppFarmManager(api)
709 try:
710 result = manager.list()
711 except TypeError:
712 pass
713 assert result is 'Exception'
714
715 def test_aspnetfarm_create(self):
716 manager = services.AspNetAppFarmManager(api)
717 result = manager.create('datacenter1', 'session1', 'test')
718 assert result.headers == {'X-Configuration-Session': 'session1'}
719 assert result.body == 'test'
720
721 def test_aspnetfarm_create_with_named_parameters(self):
722 manager = services.AspNetAppFarmManager(api)
723 result = manager.create(environment_id='datacenter1',
724 session_id='session2',
725 app_farm='test2')
726 assert result.headers == {'X-Configuration-Session': 'session2'}
727 assert result.body == 'test2'
728
729 def test_aspnetfarm_create_negative_with_two_parameters(self):
730 result = 'Exception'
731 manager = services.AspNetAppFarmManager(api)
732 try:
733 result = manager.create('datacenter1', 'session1')
734 except TypeError:
735 pass
736 assert result is 'Exception'
737
738 def test_aspnetfarm_create_negative_with_one_parameter(self):
739 result = 'Exception'
740 manager = services.AspNetAppFarmManager(api)
741 try:
742 result = manager.create('datacenter1')
743 except TypeError:
744 pass
745 assert result is 'Exception'
746
747 def test_aspnetfarm_create_negative_without_parameters(self):
748 result = 'Exception'
749 manager = services.AspNetAppFarmManager(api)
750 try:
751 result = manager.create()
752 except TypeError:
753 pass
754 assert result is 'Exception'
755
756 def test_aspnetfarm_delete(self):
757 manager = services.AspNetAppFarmManager(api)
758 result = manager.delete('datacenter1', 'session1', 'test')
759 assert result is None
760
761 def test_aspnetfarm_delete_with_named_parameters(self):
762 manager = services.AspNetAppFarmManager(api)
763 result = manager.delete(environment_id='datacenter1',
764 session_id='session1',
765 service_id='test')
766 assert result is None
767
768 def test_aspnetfarm_delete_negative_with_two_parameters(self):
769 result = 'Exception'
770 manager = services.AspNetAppFarmManager(api)
771 try:
772 result = manager.delete('datacenter1', 'session1')
773 except TypeError:
774 pass
775 assert result == 'Exception'
776
777 def test_aspnetfarm_delete_negative_with_one_parameter(self):
778 result = 'Exception'
779 manager = services.AspNetAppFarmManager(api)
780 try:
781 result = manager.delete('datacenter1')
782 except TypeError:
783 pass
784 assert result == 'Exception'
785
786 def test_aspnetfarm_delete_negative_without_parameters(self):
787 result = 'Exception'
788 manager = services.AspNetAppFarmManager(api)
789 try:
790 result = manager.delete()
791 except TypeError:
792 pass
793 assert result == 'Exception'