-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from atmosphere.cloudservice.models import * | ||
from tools.request_factory import RequestFactory | ||
from cloudservice.api.v1.cloud import Ec2_cloud | ||
|
||
|
||
|
||
rf = RequestFactory() | ||
post_request = rf.post('/resources/v1/launchApp/', {'image_id':'emi-D9602AB9', 'instance_size':'m1.small','instance_name':'iPlant Base Image','application_id':'app1','life_time':1}) | ||
|
||
ec2_keys = Ec2_keys.objects.get(username = 'seungjin') | ||
ec2_cloud = Ec2_cloud(ec2_access_key=str(ec2_keys.ec2_access_key),ec2_secret_key=str(ec2_keys.ec2_secret_key),ec2_url=str(ec2_keys.ec2_url),s3_url=str(ec2_keys.s3_url)) | ||
|
||
ec2_cloud.launchApp(post_request) |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
|
||
#RequestFactory: Easily create mock request objects, for use in testing | ||
#http://djangosnippets.org/snippets/963/ | ||
|
||
from django.test import Client | ||
from django.core.handlers.wsgi import WSGIRequest | ||
|
||
class RequestFactory(Client): | ||
""" | ||
Class that lets you create mock Request objects for use in testing. | ||
Usage: | ||
rf = RequestFactory() | ||
get_request = rf.get('/hello/') | ||
post_request = rf.post('/submit/', {'foo': 'bar'}) | ||
This class re-uses the django.test.client.Client interface, docs here: | ||
http://www.djangoproject.com/documentation/testing/#the-test-client | ||
Once you have a request object you can pass it to any view function, | ||
just as if that view had been hooked up using a URLconf. | ||
""" | ||
def request(self, **request): | ||
""" | ||
Similar to parent class, but returns the request object as soon as it | ||
has created it. | ||
""" | ||
environ = { | ||
'HTTP_COOKIE': self.cookies, | ||
'PATH_INFO': '/', | ||
'QUERY_STRING': '', | ||
'REQUEST_METHOD': 'GET', | ||
'SCRIPT_NAME': '', | ||
'SERVER_NAME': 'testserver', | ||
'SERVER_PORT': 80, | ||
'SERVER_PROTOCOL': 'HTTP/1.1', | ||
} | ||
method = "POST" | ||
environ.update(self.defaults) | ||
environ.update(request) | ||
return WSGIRequest(environ) |