Permalink
Browse files

Moved repo from being under default qa/robotframework repo

  • Loading branch information...
1 parent e41b72e commit fb59163750303a7fc85798d8747f91e13d871f64 Jerry Schneider committed Jul 20, 2012
View
@@ -0,0 +1,9 @@
+build/
+*.pyc
+.idea
+.DS_Store
+downloads/
+report.html
+output.xml
+log.html
+
View
@@ -1,5 +1,5 @@
setup.py
src/MongoDBLibrary/__init__.py
-src/MongoDBLibrary/assertion.py
-src/MongoDBLibrary/connection_manager.py
-src/MongoDBLibrary/query.py
+src/MongoDBLibrary/mongo_connection_manager.py
+src/MongoDBLibrary/mongoquery.py
+src/MongoDBLibrary/version.py
View
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-# Copyright (c) 2011 Jerry Schneider
+# Copyright (c) 2012 Jerry Schneider
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,22 +15,26 @@
# limitations under the License.
-"""Setup script for Robot's MongoDBLibrary distributions"""
+"""Setup script for Robot's MongoDB Library distributions"""
from distutils.core import setup
import sys, os
-sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
+#sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
+sys.path.insert(0, os.path.join('src','MongoDBLibrary'))
-from MongoDBLibrary import __version__
+from version import VERSION
+
+#from MongoDBLibrary import __version__
def main():
setup(name = 'robotframework-mongodblibrary',
- version = __version__,
- description = 'MongoDB Database library for Robot Framework',
+ version = VERSION,
+ #version = __version__,
+ description = 'Mongo Database utility library for Robot Framework',
author = 'Jerry Schneider',
- author_email = 'jerry57@gmail.com',
- url = 'https://github.com/jerry57/Robotframework-MongoDB-Library',
+ author_email = 'jerry@iplantcollaborative.org',
+ url = 'https://github.com/',
package_dir = { '' : 'src'},
packages = ['MongoDBLibrary']
)
@@ -1,4 +1,4 @@
-# Copyright (c) 2011 Jerry Schneider
+# Copyright (c) 2012 Jerry Schneider
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,32 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from connection_manager import ConnectionManager
-from query import Query
-#from assertion import Assertion
+from mongo_connection_manager import MongoConnectionManager
+from mongoquery import MongoQuery
+from version import VERSION
-__version__ = '0.1'
+#__version__ = '0.1'
-#class MongoDBLibrary(ConnectionManager, Query, Assertion):
-class MongoDBLibrary(ConnectionManager, Query):
+class MongoDBLibrary(MongoConnectionManager, MongoQuery):
"""
- MongoDB Database Library contains utilities meant for Robot Framework's usage.
+ MongoDB Library contains utilities meant for Robot Framework's usage.
- This can allow you to query your database after an action has been made to verify the results.
+ This can allow you to query your Mongo database after an action has been made to verify the results.
References:
- + PyMongo - http://api.mongodb.org/python/1.9%2B/index.html
+ + PyMongo 2.2 Documentation - http://api.mongodb.org/python/2.2/
Notes:
- `compatible* - or at least theoretically it should be compatible. Currently tested only with MongoDB
- (using pymongo).`
-
Example Usage:
| # Setup |
| Connect to Database |
@@ -58,4 +54,5 @@ class MongoDBLibrary(ConnectionManager, Query):
"""
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
+ ROBOT_LIBRARY_VERSION = VERSION
@@ -0,0 +1,63 @@
+# Copyright (c) 2012 Jerry Schneider
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import ConfigParser
+from robot.api import logger
+
+class MongoConnectionManager(object):
+ """
+ Connection Manager handles the connection & disconnection to the database.
+ """
+
+ def __init__(self):
+ """
+ Initializes _dbconnection to None.
+ """
+ self._dbconnection = None
+
+ def connect_to_mongodb(self, dbHost='localhost', dbPort=27017, dbMaxPoolSize=10, dbNetworkTimeout=None, dbDocClass=dict, dbTZAware=False):
+ """
+ Loads pymongo and connects to the MongoDB host using parameters submitted.
+
+ Example usage:
+ | # To connect to foo.bar.org's MongoDB service on port 27017 |
+ | Connect To MongoDB | foo.bar.org | ${27017} |
+
+ """
+ dbapiModuleName = 'pymongo'
+ db_api_2 = __import__(dbapiModuleName);
+
+ dbPort = int(dbPort)
+ #print "host is [ %s ]" % dbHost
+ #print "port is [ %s ]" % dbPort
+ #print "pool_size is [ %s ]" % dbPoolSize
+ #print "timeout is [ %s ]" % dbTimeout
+ #print "slave_okay is [ %s ]" % dbSlaveOkay
+ #print "document_class is [ %s ]" % dbDocClass
+ #print "tz_aware is [ %s ]" % dbTZAware
+ print "| Connect To MondoDB | dbHost | dbPort | dbMaxPoolSize | dbNetworktimeout | dbDocClass | dbTZAware |"
+ print "| Connect To MondoDB | %s | %s | %s | %s | %s | %s |" % (dbHost,dbPort,dbMaxPoolSize,dbNetworkTimeout,dbDocClass,dbTZAware)
+
+ self._dbconnection = db_api_2.connection.Connection (host=dbHost, port=dbPort, max_pool_size=dbMaxPoolSize, network_timeout=dbNetworkTimeout, document_class=dbDocClass, tz_aware=dbTZAware);
+
+ def disconnect_from_mongodb(self):
+ """
+ Disconnects from the MongoDB server.
+
+ For example:
+ | Disconnect From MongoDB | # disconnects from current connection to the MongoDB server |
+ """
+ print "| Disconnect From MongoDB |"
+ self._dbconnection.disconnect()
+
Oops, something went wrong.

0 comments on commit fb59163

Please sign in to comment.