Esempio n. 1
0
 def testRead_NotConnected(self):
     key = "_Read_NotConnected"
     t = Transaction()
     t.close_connection()
     #self.assertRaises(scalaris.ConnectionError, t.read, str(self._testTime) + key)
     self.assertRaises(scalaris.NotFoundError, t.read, str(self._testTime) + key)
     t.close_connection()
Esempio n. 2
0
 def testReqTooLarge(self):
     conn = Transaction()
     data = '0' * _TOO_LARGE_REQUEST_SIZE
     key = "_ReqTooLarge"
     try:
         conn.write(str(self._testTime) + key, data)
         self.fail('The write should have failed unless yaws_max_post_data was set larger than ' + str(_TOO_LARGE_REQUEST_SIZE))
     except scalaris.ConnectionError:
         pass
     
     conn.close_connection()
Esempio n. 3
0
 def testWriteString_NotConnected(self):
     key = "_WriteString_NotConnected"
     t = Transaction()
     t.close_connection()
     #self.assertRaises(scalaris.ConnectionError, t.write, str(self._testTime) + key, _TEST_DATA[0])
     t.write(str(self._testTime) + key, _TEST_DATA[0])
     t.close_connection()
Esempio n. 4
0
    def testWriteString_NotFound(self):
        key = "_WriteString_notFound"
        t = Transaction()
        notFound = False
        try:
            t.read(str(self._testTime) + key)
        except scalaris.NotFoundError:
            notFound = True

        self.assertTrue(notFound)
        t.write(str(self._testTime) + key, _TEST_DATA[0])
        self.assertEqual(t.read(str(self._testTime) + key), _TEST_DATA[0])
        t.close_connection()
Esempio n. 5
0
 def testWriteString_NotConnected(self):
     key = "_WriteString_NotConnected"
     t = Transaction()
     t.close_connection()
     #self.assertRaises(scalaris.ConnectionError, t.write, str(self._testTime) + key, _TEST_DATA[0])
     t.write(str(self._testTime) + key, _TEST_DATA[0])
     t.close_connection()
Esempio n. 6
0
 def testWriteString_NotFound(self):
     key = "_WriteString_notFound"
     t = Transaction()
     notFound = False
     try:
         t.read(str(self._testTime) + key)
     except scalaris.NotFoundError:
         notFound = True
     
     self.assertTrue(notFound)
     t.write(str(self._testTime) + key, _TEST_DATA[0])
     self.assertEqual(t.read(str(self._testTime) + key), _TEST_DATA[0])
     t.close_connection()
Esempio n. 7
0
 def testWriteList1(self):
     key = "_testWriteList1_"
     t = scalaris.Transaction()
     
     for i in xrange(0, len(_TEST_DATA) - 1, 2):
         t.write(str(self._testTime) + key + str(i), [_TEST_DATA[i], _TEST_DATA[i + 1]])
     
     # now try to read the data:
     for i in xrange(0, len(_TEST_DATA), 2):
         actual = t.read(str(self._testTime) + key + str(i))
         self.assertEqual(actual, [_TEST_DATA[i], _TEST_DATA[i + 1]])
     
     # commit the transaction and try to read the data with a new one:
     t.commit()
     t.close_connection()
     t = Transaction()
     for i in xrange(0, len(_TEST_DATA), 2):
         actual = t.read(str(self._testTime) + key + str(i))
         self.assertEqual(actual, [_TEST_DATA[i], _TEST_DATA[i + 1]])
     
     t.close_connection()
Esempio n. 8
0
 def testRead_NotConnected(self):
     key = "_Read_NotConnected"
     t = Transaction()
     t.close_connection()
     #self.assertRaises(scalaris.ConnectionError, t.read, str(self._testTime) + key)
     self.assertRaises(scalaris.NotFoundError, t.read,
                       str(self._testTime) + key)
     t.close_connection()
Esempio n. 9
0
    def testWriteList1(self):
        key = "_testWriteList1_"
        t = scalaris.Transaction()

        for i in xrange(0, len(_TEST_DATA) - 1, 2):
            t.write(
                str(self._testTime) + key + str(i),
                [_TEST_DATA[i], _TEST_DATA[i + 1]])

        # now try to read the data:
        for i in xrange(0, len(_TEST_DATA), 2):
            actual = t.read(str(self._testTime) + key + str(i))
            self.assertEqual(actual, [_TEST_DATA[i], _TEST_DATA[i + 1]])

        # commit the transaction and try to read the data with a new one:
        t.commit()
        t.close_connection()
        t = Transaction()
        for i in xrange(0, len(_TEST_DATA), 2):
            actual = t.read(str(self._testTime) + key + str(i))
            self.assertEqual(actual, [_TEST_DATA[i], _TEST_DATA[i + 1]])

        t.close_connection()
Esempio n. 10
0
    def testReqTooLarge(self):
        conn = Transaction()
        data = '0' * _TOO_LARGE_REQUEST_SIZE
        key = "_ReqTooLarge"
        try:
            conn.write(str(self._testTime) + key, data)
            self.fail(
                'The write should have failed unless yaws_max_post_data was set larger than '
                + str(_TOO_LARGE_REQUEST_SIZE))
        except scalaris.ConnectionError:
            pass

        conn.close_connection()
Esempio n. 11
0
    def _writeSingleTest(self, key, data):
        t = Transaction()

        t.write(str(self._testTime) + key, data)
        # now try to read the data:
        self.assertEqual(t.read(str(self._testTime) + key), data)
        # commit the transaction and try to read the data with a new one:
        t.commit()
        t.close_connection()
        t = Transaction()
        self.assertEqual(t.read(str(self._testTime) + key), data)

        t.close_connection()
Esempio n. 12
0
 def testDoubleClose(self):
     t = Transaction()
     t.close_connection()
     t.close_connection()
Esempio n. 13
0
 def testWriteString(self):
     key = "_testWriteString1_"
     t = Transaction()
     
     for i in xrange(len(_TEST_DATA)):
         t.write(str(self._testTime) + key + str(i), _TEST_DATA[i])
     
     # now try to read the data:
     for i in xrange(len(_TEST_DATA)):
         actual = t.read(str(self._testTime) + key + str(i))
         self.assertEqual(actual, _TEST_DATA[i])
     
     # commit the transaction and try to read the data with a new one:
     t.commit()
     t.close_connection()
     t = Transaction()
     for i in xrange(len(_TEST_DATA)):
         actual = t.read(str(self._testTime) + key + str(i))
         self.assertEqual(actual, _TEST_DATA[i])
     
     t.close_connection()
Esempio n. 14
0
 def testAbort_NotConnected(self):
     t = Transaction()
     t.close_connection()
     #self.assertRaises(scalaris.ConnectionError, t.abort)
     t.abort()
     t.close_connection()
Esempio n. 15
0
 def testCommit_Empty(self):
     t = Transaction()
     t.commit()
     t.close_connection()
Esempio n. 16
0
 def testAbort_NotConnected(self):
     t = Transaction()
     t.close_connection()
     #self.assertRaises(scalaris.ConnectionError, t.abort)
     t.abort()
     t.close_connection()
Esempio n. 17
0
 def testAbort_Empty(self):
     t = Transaction()
     t.abort()
     t.close_connection()
Esempio n. 18
0
 def testDoubleClose(self):
     t = Transaction()
     t.close_connection()
     t.close_connection()
Esempio n. 19
0
 def testCommit_Empty(self):
     t = Transaction()
     t.commit()
     t.close_connection()
Esempio n. 20
0
 def testTransaction3(self):
     t = Transaction(conn=scalaris.JSONConnection(url=scalaris.DEFAULT_URL))
     t.close_connection()
Esempio n. 21
0
 def testTransaction3(self):
     t = Transaction(conn = scalaris.JSONConnection(url = scalaris.DEFAULT_URL))
     t.close_connection()
Esempio n. 22
0
 def testAbort_Empty(self):
     t = Transaction()
     t.abort()
     t.close_connection()
Esempio n. 23
0
 def testReqList_Empty(self):
     conn = Transaction()
     conn.req_list(conn.new_req_list())
     conn.close_connection()
Esempio n. 24
0
    def testReqList1(self):
        key = "_ReqList1_"
        conn = Transaction()

        readRequests = conn.new_req_list()
        firstWriteRequests = conn.new_req_list()
        writeRequests = conn.new_req_list()
        for i in xrange(0, len(_TEST_DATA)):
            if (i % 2) == 0:
                firstWriteRequests.add_write(
                    str(self._testTime) + key + str(i), _TEST_DATA[i])
            writeRequests.add_write(
                str(self._testTime) + key + str(i), _TEST_DATA[i])
            readRequests.add_read(str(self._testTime) + key + str(i))

        results = conn.req_list(firstWriteRequests)
        # evaluate the first write results:
        for i in xrange(0, firstWriteRequests.size()):
            conn.process_result_write(results[i])

        requests = conn.new_req_list(readRequests).extend(
            writeRequests).add_commit()
        results = conn.req_list(requests)
        self.assertEqual(requests.size(), len(results))

        # now evaluate the read results:
        for i in xrange(0, readRequests.size()):
            if (i % 2) == 0:
                actual = conn.process_result_read(results[i])
                self.assertEqual(_TEST_DATA[i], actual)
            else:
                try:
                    conn.process_result_read(results[i])
                    # a not found exception must be thrown
                    self.fail('expected a NotFoundError')
                except scalaris.NotFoundError:
                    pass

        # now evaluate the write results:
        for i in xrange(0, writeRequests.size()):
            pos = readRequests.size() + i
            conn.process_result_write(results[pos])

        # once again test reads - now all reads should be successful
        results = conn.req_list(readRequests)
        self.assertEqual(readRequests.size(), len(results))

        # now evaluate the read results:
        for i in xrange(0, readRequests.size()):
            actual = conn.process_result_read(results[i])
            self.assertEqual(_TEST_DATA[i], actual)

        conn.close_connection()
Esempio n. 25
0
 def testReqList_Empty(self):
     conn = Transaction()
     conn.req_list(conn.new_req_list())
     conn.close_connection()
Esempio n. 26
0
    def testWriteString(self):
        key = "_testWriteString1_"
        t = Transaction()

        for i in xrange(len(_TEST_DATA)):
            t.write(str(self._testTime) + key + str(i), _TEST_DATA[i])

        # now try to read the data:
        for i in xrange(len(_TEST_DATA)):
            actual = t.read(str(self._testTime) + key + str(i))
            self.assertEqual(actual, _TEST_DATA[i])

        # commit the transaction and try to read the data with a new one:
        t.commit()
        t.close_connection()
        t = Transaction()
        for i in xrange(len(_TEST_DATA)):
            actual = t.read(str(self._testTime) + key + str(i))
            self.assertEqual(actual, _TEST_DATA[i])

        t.close_connection()
Esempio n. 27
0
    def testReqList1(self):
        key = "_ReqList1_"
        conn = Transaction()
        
        readRequests = conn.new_req_list()
        firstWriteRequests = conn.new_req_list()
        writeRequests = conn.new_req_list()
        for i in xrange(0, len(_TEST_DATA)):
            if (i % 2) == 0:
                firstWriteRequests.add_write(str(self._testTime) + key + str(i), _TEST_DATA[i])
            writeRequests.add_write(str(self._testTime) + key + str(i), _TEST_DATA[i])
            readRequests.add_read(str(self._testTime) + key + str(i))
        
        results = conn.req_list(firstWriteRequests)
        # evaluate the first write results:
        for i in xrange(0, firstWriteRequests.size()):
            conn.process_result_write(results[i])

        requests = conn.new_req_list(readRequests).extend(writeRequests).add_commit()
        results = conn.req_list(requests)
        self.assertEqual(requests.size(), len(results))

        # now evaluate the read results:
        for i in xrange(0, readRequests.size()):
            if (i % 2) == 0:
                actual = conn.process_result_read(results[i])
                self.assertEqual(_TEST_DATA[i], actual)
            else:
                try:
                    conn.process_result_read(results[i])
                    # a not found exception must be thrown
                    self.fail('expected a NotFoundError')
                except scalaris.NotFoundError:
                    pass

        # now evaluate the write results:
        for i in xrange(0, writeRequests.size()):
            pos = readRequests.size() + i
            conn.process_result_write(results[pos])

        # once again test reads - now all reads should be successful
        results = conn.req_list(readRequests)
        self.assertEqual(readRequests.size(), len(results))

        # now evaluate the read results:
        for i in xrange(0, readRequests.size()):
            actual = conn.process_result_read(results[i])
            self.assertEqual(_TEST_DATA[i], actual)
        
        conn.close_connection();
Esempio n. 28
0
 def testTransaction1(self):
     t = Transaction()
     t.close_connection()
Esempio n. 29
0
 def _writeSingleTest(self, key, data):
     t = Transaction()
     
     t.write(str(self._testTime) + key, data)
     # now try to read the data:
     self.assertEqual(t.read(str(self._testTime) + key), data)
     # commit the transaction and try to read the data with a new one:
     t.commit()
     t.close_connection()
     t = Transaction()
     self.assertEqual(t.read(str(self._testTime) + key), data)
     
     t.close_connection()
Esempio n. 30
0
 def testTransaction1(self):
     t = Transaction()
     t.close_connection()