Skip to content

Commit

Permalink
added test to support db querying from a Klass object
Browse files Browse the repository at this point in the history
  • Loading branch information
emehrkay committed Dec 4, 2010
1 parent 53be942 commit 9f469ca
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# files to ignore
*.pyc
x.py
x.py
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Compass is a simple Python REST interface for the OrientDB graph document store.
Requirements
-------------
* Python 2.6
* OrientDB Rest Server
* [OrientDB Rest Server](http://www.orientechnologies.com/)

Classes
-------------
Expand Down Expand Up @@ -68,7 +68,7 @@ Connect to or retrieve an existing database. Upon database creation, three users
result_klass = demo_db.query('SELECT * FROM Address WHERE city = "Cupertino"')

**Klass Object**
The class object will eventually all you to define a schema for all documents that belong to it. The latest build of OrientDB's rest server does not allow for creation of properties that define certain attributes (required, max, min length, etc), it will in a later release
The class object will eventually allow you to define a schema for all documents that belong to it. The latest build of OrientDB's rest server does not allow for creation of properties that define certain attributes (required, max, min length, etc), it will in a later release

#retrieve a class
addresses = demo_db.klass(name='Address')
Expand Down
30 changes: 24 additions & 6 deletions tests.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#!/usr/bin/env python
# encoding: utf-8

import sys
import os
import unittest
from client import *
import random

username = 'root'
password = 'EDEBF121682BF71D0DEDB82459E6B772CDD291F3C0765D7C6B104420604F269C'
password = 'AFE1D46E7A5FC722CBD5821644B03BD57CC782B7A1585D438A0414CE0B8DE73D'
url = 'http://localhost:2480'
server = Server(url=url, username=username, password=password)

Expand Down Expand Up @@ -152,10 +150,12 @@ def test_can_query_database(self):
try:
query = 'select * from %s' % (class_name)
database = server.database(name=class_db_name)
klass = database.query(query=query)

database.query(query=query)

result = True
if isinstance(klass, Klass):
result = True
else:
reslut = False
except CompassException, e:
result = False

Expand Down Expand Up @@ -290,6 +290,24 @@ def test_can_delete_property(self):
result = False;

self.assertTrue(result)

def test_can_run_query_and_get_results(self):
try:
class_name = randomName('new_class', 2)
new_class = self.database.klass(name=class_name, create=True)
doc1 = new_class.document(name=randomName('random_doc', 3))
doc2 = new_class.document(name=randomName('random_doc', 3))
query = 'select * from %s' % (class_name)
new_class.query(query=query)

if len(new_class) == 2:
result = True
else:
result = False
except CompassException, e:
result = False

self.assertTrue(result)

if __name__ == '__main__':
server_suite = unittest.TestLoader().loadTestsFromTestCase(ServerTests)
Expand Down

0 comments on commit 9f469ca

Please sign in to comment.