Skip to content

Commit

Permalink
Reviewing Reform
Browse files Browse the repository at this point in the history
  • Loading branch information
Msekni Bilel committed Nov 20, 2012
1 parent 8aa018e commit 8a88288
Show file tree
Hide file tree
Showing 38 changed files with 56 additions and 1,016 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Thumbs.db
build/
dist/
pyocni.egg-info/
pyocni/TDD

# Testing file
#########################
Expand Down
2 changes: 1 addition & 1 deletion HTTP_HowTo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ It's up to the user to define what format he wants in the request Content-Type h

N/A

4.Full Update of a category (Kind or Mixin or Action)::
4.Update of a category (Kind or Mixin or Action)::

curl -X PUT -d@put_category -H 'content-type: text/plain' -H 'accept: text/plain' -v http://localhost:8090/-/

Expand Down
25 changes: 25 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ PyOCNI offers two OCCI rendering formats : **HTTP and JSON**. The following comm

N/A

6.Update a kind provider::

curl -X PUT -d@update_provider.json -H 'content-type: application/occi+json' -H 'accept: application/occi+json' -v http://localhost:8090/-/

* Response::

N/A

4.2. Path management
----------------------
Expand Down Expand Up @@ -617,6 +624,24 @@ Some of pyocni's needs might be:
]
}

* update_provider.json::

{
"providers": [
{
"Provider": {
"local": [
"dummy"
],
"remote": [
"Bilel"
]
},
"OCCI_ID": "http://schemas.ogf.org/occi/infrastructure#compute"
}
]
}

* get_resources.json::

{
Expand Down
24 changes: 13 additions & 11 deletions pyocni/TDD/Tests/queryInterface_Tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ def setUp(self):
self.p = Process(target=start_server)
self.p.start()
time.sleep(0.5)
init_fakeDB()
#init_fakeDB()
time.sleep(0.5)

def tearDown(self):
config.purge_PyOCNI_db()

#config.purge_PyOCNI_db()
self.p.terminate()

def test_get_categories(self):
Expand All @@ -64,9 +65,9 @@ def test_get_categories(self):
storage = StringIO.StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://127.0.0.1:8090/-/')
c.setopt(c.HTTPHEADER, ['Accept:text/plain'])
c.setopt(c.HTTPHEADER, ['Accept:application/occi+json','content-type:application/occi+json'])
c.setopt(c.VERBOSE, True)
#c.setopt(c.POSTFIELDS,f_entities.action_occci_id)
c.setopt(c.POSTFIELDS,f_categories.kind)
c.setopt(c.CUSTOMREQUEST, 'GET')
c.setopt(c.WRITEFUNCTION, storage.write)
c.perform()
Expand All @@ -86,7 +87,7 @@ def setUp(self):
self.p = Process(target=start_server)
self.p.start()
time.sleep(0.5)
#init_fakeDB()
init_fakeDB()
time.sleep(0.5)

def tearDown(self):
Expand All @@ -103,8 +104,8 @@ def test_delete_categories(self):

c.setopt(c.CUSTOMREQUEST, 'DELETE')
c.setopt(c.URL, 'http://127.0.0.1:8090/-/')
c.setopt(c.HTTPHEADER, ['Accept: application/occi+json', 'Content-Type: text/plain'])
c.setopt(c.POSTFIELDS, f_categories.action_occci_id)
c.setopt(c.HTTPHEADER, ['Accept: application/occi+json', 'Content-Type: application/occi+json'])
c.setopt(c.POSTFIELDS, f_categories.kind)
c.setopt(c.VERBOSE, True)
c.setopt(c.WRITEFUNCTION, storage.write)

Expand All @@ -129,6 +130,7 @@ def setUp(self):
time.sleep(0.5)

def tearDown(self):

self.p.terminate()
#config.purge_PyOCNI_db()

Expand All @@ -141,9 +143,9 @@ def test_register_categories(self):
storage = StringIO.StringIO()

c.setopt(c.URL, 'http://127.0.0.1:8090/-/')
c.setopt(c.HTTPHEADER, ['Content-Type: text/plain', 'Accept: application/occi+json'])
c.setopt(c.HTTPHEADER, ['Content-Type: application/occi+json', 'Accept: application/occi+json'])

c.setopt(c.POSTFIELDS, f_categories.kind_http)
c.setopt(c.POSTFIELDS, f_categories.kind)
c.setopt(c.CUSTOMREQUEST, 'POST')
c.setopt(c.WRITEFUNCTION, storage.write)

Expand Down Expand Up @@ -181,7 +183,7 @@ def test_update_categories(self):
c.setopt(c.URL, 'http://127.0.0.1:8090/-/')
c.setopt(c.HTTPHEADER, ['Content-Type: application/occi+json', 'Accept: application/occi+json'])
c.setopt(c.CUSTOMREQUEST, 'PUT')
c.setopt(c.POSTFIELDS, f_categories.action)
c.setopt(c.POSTFIELDS, f_categories.put_provider)
c.setopt(c.WRITEFUNCTION, storage.write)
c.perform()
content = storage.getvalue()
Expand All @@ -203,4 +205,4 @@ def test_update_categories(self):

#Run tests

runner.run(put_suite)
runner.run(delete_suite)
26 changes: 7 additions & 19 deletions pyocni/TDD/fake_Data/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"title": "Start Compute instance now",
"attributes": {
"method": {
"mutable": true,
"mutable": false,
"required": false,
"type": "string",
"pattern": "graceful|acpion|poweron",
Expand Down Expand Up @@ -140,16 +140,6 @@
}
"""

provider_up = """
{
"Providers": {
"remote": [],
"local": [
"dummy"
]
}
}"""

action_plus_attributes =\
"""
{
Expand Down Expand Up @@ -192,8 +182,8 @@
#=======================================================================================================================

kind_occci_id = """Category: compute;
scheme="http://schemas.ogf.org/occi/infrastructure#";
class=kind;
scheme="http://schemas.ogf.org/occi/infrastructure#";
class=kind;
"""
#=======================================================================================================================

Expand All @@ -203,9 +193,7 @@
"""
#=======================================================================================================================

action_occci_id = """Category: start;
scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";
class=action;
action_occci_id = """Category: start;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#"; class=action;
"""
#=======================================================================================================================

Expand All @@ -214,16 +202,16 @@
"class=\"mixin\";"\
"title=\"Storage Resource\";"\
"location=\"/my_stuff/\";"\
"attributes=\"occi.storage.size{required} occi.storage.state{immutable}\";"\
"attributes=\"occi.storage.size{required},occi.storage.state{immutable}\";"\
\
#=======================================================================================================================

kind_http = "Category: compute;"\
kind_http = "Category: compute5;"\
"scheme=\"http://schemas.ogf.org/occi/infrastructure#\";"\
"class=\"kind\";"\
"title=\"Compute Resource type\";"\
"rel=\"http://schemas.ogf.org/occi/core#resource\";"\
"attributes=\"occi.compute.cores occi.compute.state{immutable}\";"\
"attributes=\"occi.compute.cores, occi.compute.state{immutable}\";"\
"actions=\"http://schemas.ogf.org/occi/infrastructure/compute/action#stop\";"\
"location=\"http://example.com/compute/\""
#=======================================================================================================================
Expand Down
1 change: 1 addition & 0 deletions pyocni/TDD/fake_Data/initialize_fakeDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def init_fakeDB():
add_fake_action()
add_fake_kind()
add_fake_mixin()
add_fake_resource()


def add_fake_kind():
Expand Down
20 changes: 0 additions & 20 deletions pyocni/TDD/request_examples/delete_actions.json

This file was deleted.

31 changes: 0 additions & 31 deletions pyocni/TDD/request_examples/delete_categories.json

This file was deleted.

16 changes: 0 additions & 16 deletions pyocni/TDD/request_examples/delete_kinds.json

This file was deleted.

15 changes: 0 additions & 15 deletions pyocni/TDD/request_examples/delete_mixins.json

This file was deleted.

39 changes: 0 additions & 39 deletions pyocni/TDD/request_examples/filter_categories.json

This file was deleted.

36 changes: 0 additions & 36 deletions pyocni/TDD/request_examples/full_update_link.json

This file was deleted.

Loading

0 comments on commit 8a88288

Please sign in to comment.