Exemplo n.º 1
0
        print("PASSED TEST STRESSED ROLBACK")

    def abort_test(self):
        print("TEST FAILED")
        sys.exit(1)


if __name__ == '__main__':
    os.system('rm config.txt; touch config.txt')
    parser = OptionParser()

    #-m is for the main address, which is a host:port pair, ideally of the
    #mongos. For non sharded clusters, it can be the primary.
    parser.add_option("-m", "--main", action="store", type="string",
                      dest="main_addr", default="27217")

    (options, args) = parser.parse_args()
    PORTS_ONE['MONGOS'] = options.main_addr
    doc_manager = DocManager('localhost:30000')
    doc_manager._remove()

    start_cluster()

    conn = Connection('localhost:' + PORTS_ONE['MONGOS'],
                      replicaSet="demo-repl")
    print("STARTING TESTS")
    unittest.main(argv=[sys.argv[0]])

    print("Done with tests")
    clean_up()
file = inspect.getfile(inspect.currentframe())
cmd_folder = os.path.realpath(os.path.abspath(os.path.split(file)[0]))
doc_folder = cmd_folder.rsplit("/", 2)[0]
doc_folder += '/doc_managers'
if doc_folder not in sys.path:
    sys.path.insert(0, doc_folder)

mongo_folder = cmd_folder.rsplit("/", 2)[0]
if mongo_folder not in sys.path:
    sys.path.insert(0, mongo_folder)

from mongo_doc_manager import DocManager
from pymongo import Connection

MongoDoc = DocManager("localhost:30000")
mongo = Connection("localhost:30000")['test']['test']


class MongoDocManagerTester(unittest.TestCase):
    """Test class for MongoDocManager
    """
    def runTest(self):
        unittest.TestCase.__init__(self)

    def setUp(self):
        """Empty Mongo at the start of every test
        """
        mongo.remove()

    def test_upsert(self):
        print("PASSED TEST STRESSED ROLBACK")

    def abort_test(self):
        print("TEST FAILED")
        sys.exit(1)


if __name__ == '__main__':
    os.system('rm config.txt; touch config.txt')
    parser = OptionParser()

    #-m is for the main address, which is a host:port pair, ideally of the
    #mongos. For non sharded clusters, it can be the primary.
    parser.add_option("-m", "--main", action="store", type="string",
                      dest="main_addr", default="27217")

    (options, args) = parser.parse_args()
    PORTS_ONE['MONGOS'] = options.main_addr
    s = DocManager('localhost:30000')
    s._remove()

    start_cluster()

    conn = Connection('localhost:' + PORTS_ONE['MONGOS'],
                      replicaSet="demo-repl")
    print("STARTING TESTS")
    unittest.main(argv=[sys.argv[0]])

    print("Done with tests")
    clean_up()