def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() s = 'transport_2011-07-25_19-05-49' self._make_submission( os.path.join(self.this_directory, 'fixtures', 'transportation', 'instances', s, s + '.xml')) self.submission = self.xform.instances.reverse()[0] self.url = reverse(map_view, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.perm_url = reverse(set_perm, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.edit_url = reverse(edit, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.show_url = reverse(show, kwargs={'uuid': self.xform.uuid}) self.show_normal_url = reverse(show, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.api_url = reverse(api, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): TestBase.set_up(self) self.shardkeys = [0, 1] ids = [0, 1, 2, 3, 4, 5] write_multiple_request = WriteMultipleRequest() for sk in self.shardkeys: for i in ids: row = {'fld_sid': sk, 'fld_id': i, 'fld_long': 2147483648, 'fld_float': 3.1414999961853027, 'fld_double': 3.1415, 'fld_bool': True, 'fld_str': '{"name": u1, "phone": null}', 'fld_bin': bytearray(pack('>i', 4)), 'fld_time': datetime.now(), 'fld_num': Decimal(5), 'fld_json': {'a': '1', 'b': None, 'c': '3'}, 'fld_arr': ['a', 'b', 'c'], 'fld_map': {'a': '1', 'b': '2', 'c': '3'}, 'fld_rec': {'fld_id': 1, 'fld_bool': False, 'fld_str': None}} write_multiple_request.add( PutRequest().set_value(row).set_table_name(table_name), True) self.handle.write_multiple(write_multiple_request) write_multiple_request.clear() self.key = {'fld_sid': 1} self.multi_delete_request = MultiDeleteRequest().set_timeout(timeout) prep_request = PrepareRequest().set_statement( 'SELECT fld_sid, fld_id FROM ' + table_name) prep_result = self.handle.prepare(prep_request) self.query_request = QueryRequest().set_prepared_statement(prep_result)
def setUpClass(cls): TestBase.set_up_class() index_name = 'idx_' + table_name create_statement = ('CREATE TABLE ' + table_name + '(fld_sid INTEGER, fld_id INTEGER, \ fld_long LONG, fld_float FLOAT, fld_double DOUBLE, fld_bool BOOLEAN, \ fld_str STRING, fld_bin BINARY, fld_time TIMESTAMP(6), fld_num NUMBER, \ fld_json JSON, fld_arr ARRAY(STRING), fld_map MAP(STRING), \ fld_rec RECORD(fld_id LONG, fld_bool BOOLEAN, fld_str STRING), \ PRIMARY KEY(SHARD(fld_sid), fld_id))') limits = TableLimits(5000, 5000, 50) create_request = TableRequest().set_statement( create_statement).set_table_limits(limits) cls._result = TestBase.table_request(create_request, State.ACTIVE) create_index_statement = ('CREATE INDEX ' + index_name + ' ON ' + table_name + '(fld_long)') create_index_request = TableRequest().set_statement( create_index_statement) cls._result = TestBase.table_request(create_index_request, State.ACTIVE) global prepare_cost prepare_cost = 2 global query_statement query_statement = ('SELECT fld_sid, fld_id FROM ' + table_name + ' WHERE fld_sid = 1')
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() s = 'transport_2011-07-25_19-05-49' self._make_submission(os.path.join( self.this_directory, 'fixtures', 'transportation', 'instances', s, s + '.xml')) self.submission = self.xform.instances.reverse()[0] self.url = reverse(map_view, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string}) self.perm_url = reverse(set_perm, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string}) self.edit_url = reverse(edit, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.show_url = reverse(show, kwargs={'uuid': self.xform.uuid}) self.show_normal_url = reverse(show, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.api_url = reverse(api, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def tearDown(self): for sk in self.shardkeys: key = {'fld_sid': sk} request = MultiDeleteRequest().set_table_name( table_name).set_key(key) self.handle.multi_delete(request) TestBase.tear_down(self)
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() self.url = reverse(show, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance() self.public_api_url = reverse(public_api, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance() self.api_url = reverse(api, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): TestBase.set_up(self) self.handle_config = get_handle_config(tenant_id) shardkeys = [0, 1] ids = [0, 1, 2, 3, 4, 5] write_multiple_request = WriteMultipleRequest() for sk in shardkeys: for i in ids: row = { 'fld_sid': sk, 'fld_id': i, 'fld_long': 2147483648, 'fld_float': 3.1414999961853027, 'fld_double': 3.1415, 'fld_bool': True, 'fld_str': '{"name": u1, "phone": null}', 'fld_bin': bytearray(pack('>i', 4)), 'fld_time': datetime.now(), 'fld_num': Decimal(5), 'fld_json': { 'a': '1', 'b': None, 'c': '3' }, 'fld_arr': ['a', 'b', 'c'], 'fld_map': { 'a': '1', 'b': '2', 'c': '3' }, 'fld_rec': { 'fld_id': 1, 'fld_bool': False, 'fld_str': None } } write_multiple_request.add( PutRequest().set_value(row).set_table_name(table_name), True) self.handle.write_multiple(write_multiple_request) write_multiple_request.clear() prepare_statement_update = ( 'DECLARE $fld_sid INTEGER; $fld_id INTEGER; UPDATE ' + table_name + ' u SET u.fld_long = u.fld_long + 1 WHERE fld_sid = $fld_sid ' + 'AND fld_id = $fld_id') prepare_request_update = PrepareRequest().set_statement( prepare_statement_update) self.prepare_result_update = self.handle.prepare( prepare_request_update) prepare_statement_select = ( 'DECLARE $fld_long LONG; SELECT fld_sid, fld_id, fld_long FROM ' + table_name + ' WHERE fld_long = $fld_long') prepare_request_select = PrepareRequest().set_statement( prepare_statement_select) self.prepare_result_select = self.handle.prepare( prepare_request_select) self.query_request = QueryRequest().set_timeout(timeout) self.get_request = GetRequest().set_table_name(table_name)
def setUpClass(cls): TestBase.set_up_class() create_statement = ('CREATE TABLE ' + table_name + '(fld_id INTEGER, fld_long LONG, \ fld_float FLOAT, fld_double DOUBLE, fld_bool BOOLEAN, fld_str STRING, \ fld_bin BINARY, fld_time TIMESTAMP(7), fld_num NUMBER, fld_json JSON, \ fld_arr ARRAY(STRING), fld_map MAP(STRING), \ fld_rec RECORD(fld_id LONG, fld_bool BOOLEAN, fld_str STRING), \ PRIMARY KEY(fld_id)) USING TTL 1 HOURS') limits = TableLimits(5000, 5000, 50) create_request = TableRequest().set_statement( create_statement).set_table_limits(limits) cls._result = TestBase.table_request(create_request, State.ACTIVE) # put and get some data, read_units = 100, write_units = 199 row = { 'fld_id': 1, 'fld_long': 2147483648, 'fld_float': 3.1414999961853027, 'fld_double': 3.1415, 'fld_bool': True, 'fld_str': '{"name": u1, "phone": null}', 'fld_bin': bytearray(pack('>i', 4)), 'fld_time': datetime.now(), 'fld_num': Decimal(5), 'fld_json': { 'a': '1', 'b': None, 'c': '3' }, 'fld_arr': ['a', 'b', 'c'], 'fld_map': { 'a': '1', 'b': '2', 'c': '3' }, 'fld_rec': { 'fld_id': 1, 'fld_bool': False, 'fld_str': None } } key = {'fld_id': 1} put_request = PutRequest().set_value(row).set_table_name(table_name) get_request = GetRequest().set_key(key).set_table_name(table_name) count = 0 while count < 100: cls._handle.put(put_request) cls._handle.get(get_request) count += 1 # sleep to allow records to accumulate over time, but not if # using Cloudsim. if not_cloudsim(): sleep(2) # need to sleep to allow usage records to accumulate but not if # using CloudSim, which doesn't generate usage records. if not_cloudsim(): sleep(40)
def _publish_transportation_id_string_starts_with_number_form(self): xls_path = os.path.join(self.this_directory, "fixtures", "transportation", "transportation.id_starts_with_num.xls") count = XForm.objects.count() TestBase._publish_xls_file(self, xls_path) self.assertEqual(XForm.objects.count(), count + 1) self.xform = XForm.objects.all().reverse()[0]
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance() self.perm_url = reverse(set_perm, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string}) self.show_url = reverse(show, kwargs={'uuid': self.xform.uuid}) self.url = reverse(enter_data, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): TestBase.setup(self) self.name = u"name" self._domain = u"Microblog" self.author_guid = unicode(generate_random_guid()) self.new_author_name = u"new_author_name" self.umlaut_author_name = u"loegfo__fuuhde☺☻♥♥♥Ää" self.umlaut_author_full_name = u"✫veronica✫Ää" self.umlaut_author_description = u"ⒷritainsⒷestⒸhoiceÄ ä" self.umlaut_language = u"カリムスキー☺☻♥♦♣♠•◘○Ä ä" self.umlaut_location = u"猫パンチÄ ä"
def tearDown(self): try: TableResult.wait_for_state(self.handle, table_name, State.ACTIVE, wait_timeout, 1000) drop_request = TableRequest().set_statement(self.drop_tb_statement) result = self.handle.table_request(drop_request) result.wait_for_state(self.handle, table_name, State.DROPPED, wait_timeout, 1000) except TableNotFoundException: pass finally: TestBase.tear_down(self)
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance() self.delete_url = reverse(delete_data, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.mongo_args = { 'username': self.user.username, 'id_string': self.xform.id_string, 'query': "{}", 'limit': 1, 'sort': '{"_id":-1}', 'fields': '["_id","_uuid"]'}
def setUp(self): TestBase.setUp(self) self.session = ShardedSession(self.shardconf, DjangoVShardLoader()) # modify configuration: reduce capacity for this test and check often for shard in self.session.shards: while shard != None: shard.capacity_MB = 1 shard.SIZE_CHECK_INTERVAL = 100 shard = shard.next self.keepers = self.loadOrCreateData('virtual-user-pickle')
def test_uuid_injection_in_cascading_select(self): """ Uuid is injected in the right instance for forms with cascading select """ pre_count = XForm.objects.count() xls_path = os.path.join(self.this_directory, "fixtures", "cascading_selects", "new_cascading_select.xls") file_name, file_ext = os.path.splitext(os.path.split(xls_path)[1]) TestBase._publish_xls_file(self, xls_path) post_count = XForm.objects.count() self.assertEqual(post_count, pre_count + 1) xform = XForm.objects.latest('date_created') # check that the uuid is within the main instance/ # the one without an id attribute xml = clean_and_parse_xml(xform.xml) # check for instance nodes that are direct children of the model node model_node = xml.getElementsByTagName("model")[0] instance_nodes = [ node for node in model_node.childNodes if node.nodeType == Node.ELEMENT_NODE and node.tagName.lower() == "instance" and not node.hasAttribute("id") ] self.assertEqual(len(instance_nodes), 1) instance_node = instance_nodes[0] # get the first element whose id attribute is equal to our form's # id_string form_nodes = [ node for node in instance_node.childNodes if node.nodeType == Node.ELEMENT_NODE and node.getAttribute("id") == xform.id_string ] form_node = form_nodes[0] # find the formhub node that has a uuid child node formhub_nodes = form_node.getElementsByTagName("formhub") self.assertEqual(len(formhub_nodes), 1) uuid_nodes = formhub_nodes[0].getElementsByTagName("uuid") self.assertEqual(len(uuid_nodes), 1) # check for the calculate bind calculate_bind_nodes = [ node for node in model_node.childNodes if node.nodeType == Node.ELEMENT_NODE and node.tagName == "bind" and node.getAttribute("nodeset") == "/%s/formhub/uuid" % file_name ] self.assertEqual(len(calculate_bind_nodes), 1) calculate_bind_node = calculate_bind_nodes[0] self.assertEqual(calculate_bind_node.getAttribute("calculate"), "'%s'" % xform.uuid)
def setUpClass(cls): TestBase.set_up_class() create_statement = ( 'CREATE TABLE ' + table_name + '(fld_sid INTEGER, fld_id INTEGER, \ fld_long LONG, fld_float FLOAT, fld_double DOUBLE, fld_bool BOOLEAN, \ fld_str STRING, fld_bin BINARY, fld_time TIMESTAMP(8), fld_num NUMBER, \ fld_json JSON, fld_arr ARRAY(STRING), fld_map MAP(STRING), \ fld_rec RECORD(fld_id LONG, fld_bool BOOLEAN, fld_str STRING), \ PRIMARY KEY(SHARD(fld_sid), fld_id))') limits = TableLimits(5000, 5000, 50) create_request = TableRequest().set_statement( create_statement).set_table_limits(limits) cls._result = TestBase.table_request(create_request, State.ACTIVE)
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() # turn on crowd forms for this form self.xform.is_crowd_form = True self.xform.save() self.edit_url = reverse(edit, kwargs={ 'username': self.xform.user.username, 'id_string': self.xform.id_string }) self.alice = 'alice' self.crowdform_count = 0
def setUpClass(cls): TestBase.set_up_class() create_statement = ( 'CREATE TABLE ' + table_name + '(fld_id INTEGER, fld_long LONG, \ fld_float FLOAT, fld_double DOUBLE, fld_bool BOOLEAN, fld_str STRING, \ fld_bin BINARY, fld_time TIMESTAMP(6), fld_num NUMBER, fld_json JSON, \ fld_arr ARRAY(STRING), fld_map MAP(STRING), \ fld_rec RECORD(fld_id LONG, fld_bool BOOLEAN, fld_str STRING), \ PRIMARY KEY(fld_id)) USING TTL 2 DAYS') create_request = TableRequest().set_statement( create_statement).set_table_limits(TableLimits(5000, 5000, 50)) cls._result = TestBase.table_request(create_request, State.ACTIVE) global hour_in_milliseconds hour_in_milliseconds = 60 * 60 * 1000
def setUpClass(cls): TestBase.set_up_class() global table_ttl table_ttl = TimeToLive.of_days(30) create_statement = ('CREATE TABLE ' + table_name + '(fld_id INTEGER, fld_long LONG, \ fld_float FLOAT, fld_double DOUBLE, fld_bool BOOLEAN, fld_str STRING, \ fld_bin BINARY, fld_time TIMESTAMP(9), fld_num NUMBER, fld_json JSON, \ fld_arr ARRAY(STRING), fld_map MAP(STRING), \ fld_rec RECORD(fld_id LONG, fld_bool BOOLEAN, fld_str STRING), \ PRIMARY KEY(fld_id)) USING TTL ' + str(table_ttl)) create_request = TableRequest().set_statement( create_statement).set_table_limits(TableLimits(5000, 5000, 50)) cls._result = TestBase.table_request(create_request, State.ACTIVE)
def test_uuid_injection_in_cascading_select(self): """Test that the uuid is injected in the right instance node for forms with a cascading select""" pre_count = XForm.objects.count() xls_path = os.path.join( self.this_directory, "fixtures", "cascading_selects", "new_cascading_select.xls") file_name, file_ext = os.path.splitext(os.path.split(xls_path)[1]) TestBase._publish_xls_file(self, xls_path) post_count = XForm.objects.count() self.assertEqual(post_count, pre_count + 1) xform = XForm.objects.latest('date_created') # check that the uuid is within the main instance/ # the one without an id attribute xml = clean_and_parse_xml(xform.xml) # check for instance nodes that are direct children of the model node model_node = xml.getElementsByTagName("model")[0] instance_nodes = [node for node in model_node.childNodes if node.nodeType == Node.ELEMENT_NODE and node.tagName.lower() == "instance" and not node.hasAttribute("id")] self.assertEqual(len(instance_nodes), 1) instance_node = instance_nodes[0] # get the first element whose id attribute is equal to our form's # id_string form_nodes = [node for node in instance_node.childNodes if node.nodeType == Node.ELEMENT_NODE and node.getAttribute("id") == xform.id_string] form_node = form_nodes[0] # find the formhub node that has a uuid child node formhub_nodes = form_node.getElementsByTagName("formhub") self.assertEqual(len(formhub_nodes), 1) uuid_nodes = formhub_nodes[0].getElementsByTagName("uuid") self.assertEqual(len(uuid_nodes), 1) # check for the calculate bind calculate_bind_nodes = [node for node in model_node.childNodes if node.nodeType == Node.ELEMENT_NODE and node.tagName == "bind" and node.getAttribute("nodeset") == "/%s/formhub/uuid" % file_name] self.assertEqual(len(calculate_bind_nodes), 1) calculate_bind_node = calculate_bind_nodes[0] self.assertEqual( calculate_bind_node.getAttribute("calculate"), "'%s'" % xform.uuid)
def tearDownClass(self): looked_up = TestBase.getDAO().download_sampling_events_by_os_attr('oxford_id', '123456') looked_up = looked_up.sampling_events[0] TestBase.getDAO().delete_sampling_event(looked_up.sampling_event_id) looked_up = TestBase.getDAO().download_original_samples_by_attr('oxford_id', '123456') looked_up = looked_up.original_samples[0] TestBase.getDAO().delete_original_sample(looked_up.original_sample_id) TestBase.deleteEventSets(['multiple_study'], TestSampling_Event._locations) TestBase.tearDownLocations(TestSampling_Event._locations)
def _publish_file(self, xls_path, strict=True): """ Return False if not strict and publish fails """ pre_count = XForm.objects.count() TestBase._publish_xls_file(self, xls_path) # make sure publishing the survey worked if XForm.objects.count() != pre_count + 1: # print file location print '\nPublish Failure for file: %s' % xls_path if strict: self.assertEqual(XForm.objects.count(), pre_count + 1) else: return False self.xform = list(XForm.objects.all())[-1] return True
def _publish_file(self, xls_path, strict=True): """ Returns False if not strict and publish fails """ pre_count = XForm.objects.count() TestBase._publish_xls_file(self, xls_path) # make sure publishing the survey worked if XForm.objects.count() != pre_count + 1: # print file location print '\nPublish Failure for file: %s' % xls_path if strict: self.assertEqual(XForm.objects.count(), pre_count + 1) else: return False self.xform = list(XForm.objects.all())[-1] return True
def setUpClass(cls): TestBase.set_up_class() table_ttl = TimeToLive.of_hours(16) create_statement = ('CREATE TABLE ' + table_name + '(fld_sid INTEGER, fld_id INTEGER, \ fld_long LONG, fld_float FLOAT, fld_double DOUBLE, fld_bool BOOLEAN, \ fld_str STRING, fld_bin BINARY, fld_time TIMESTAMP(7), fld_num NUMBER, \ fld_json JSON, fld_arr ARRAY(STRING), fld_map MAP(STRING), \ fld_rec RECORD(fld_id LONG, fld_bool BOOLEAN, fld_str STRING), \ PRIMARY KEY(SHARD(fld_sid), fld_id)) USING TTL ' + str(table_ttl)) create_request = TableRequest().set_statement( create_statement).set_table_limits(TableLimits(5000, 5000, 50)) cls._result = TestBase.table_request(create_request, State.ACTIVE) global row, tb_expect_expiration, hour_in_milliseconds row = { 'fld_sid': 1, 'fld_id': 1, 'fld_long': 2147483648, 'fld_float': 3.1414999961853027, 'fld_double': 3.1415, 'fld_bool': True, 'fld_str': '{"name": u1, "phone": null}', 'fld_bin': bytearray(pack('>i', 4)), 'fld_time': datetime.now(), 'fld_num': Decimal(5), 'fld_json': { 'a': '1', 'b': None, 'c': '3' }, 'fld_arr': ['a', 'b', 'c'], 'fld_map': { 'a': '1', 'b': '2', 'c': '3' }, 'fld_rec': { 'fld_id': 1, 'fld_bool': False, 'fld_str': None } } put_request = PutRequest().set_value(row).set_table_name(table_name) cls._handle.put(put_request) tb_expect_expiration = table_ttl.to_expiration_time( int(round(time() * 1000))) hour_in_milliseconds = 60 * 60 * 1000
def setUp(self): TestBase.set_up(self) self.row = {'fld_id': 1, 'fld_long': 2147483648, 'fld_float': 3.1414999961853027, 'fld_double': 3.1415, 'fld_bool': True, 'fld_str': '{"name": u1, "phone": null}', 'fld_bin': bytearray(pack('>i', 4)), 'fld_time': datetime.now(), 'fld_num': Decimal(5), 'fld_json': {'a': '1', 'b': None, 'c': '3'}, 'fld_arr': ['a', 'b', 'c'], 'fld_map': {'a': '1', 'b': '2', 'c': '3'}, 'fld_rec': {'fld_id': 1, 'fld_bool': False, 'fld_str': None}} self.key = {'fld_id': 1} self.put_request = PutRequest().set_value(self.row).set_table_name( table_name) self.version = self.handle.put(self.put_request).get_version() self.get_request = GetRequest().set_key(self.key).set_table_name( table_name) self.delete_request = DeleteRequest().set_key(self.key).set_table_name( table_name).set_timeout(timeout)
def test_publish_bad_xls_with_unicode_in_error(self): """ Check that publishing a bad xls where the error has a unicode character returns a 200, thus showing a readable error to the user """ self._create_user_and_login() path = os.path.join(self.this_directory, 'fixtures', 'form_with_unicode_in_relevant_column.xlsx') response = TestBase._publish_xls_file(self, path) # make sure we get a 200 response self.assertEqual(response.status_code, 200)
def test_publish_bad_xls_with_unicode_in_error(self): """ Check that publishing a bad xls where the error has a unicode character returns a 200, thus showing a readable error to the user """ self._create_user_and_login() path = os.path.join( self.this_directory, 'fixtures', 'form_with_unicode_in_relevant_column.xlsx') response = TestBase._publish_xls_file(self, path) # make sure we get a 200 response self.assertEqual(response.status_code, 200)
def tearDownClass(self): TestBase.deleteStudies(['9030'], TestROMA._locations) TestBase.tearDownLocations(TestROMA._locations) TestBase.deleteEventSets(['roma_dump', 'roma_MNF00001'], TestROMA._locations)
def setUpClass(cls): TestBase.set_up_class() cls._drop_requests = list() global table_names, index_names, num_indexes, index_fields table_names = list() num_tables = 2 index_names = list() num_indexes = 1 index_fields = list() for index in range(2): index_fields.append(list()) index_fields[0].append('fld_double') index_fields[1].append('fld_str') for table in range(num_tables): tb_name = table_name + str(table) table_names.append(tb_name) create_statement = ('CREATE TABLE ' + tb_name + '(fld_id INTEGER, \ fld_long LONG, fld_float FLOAT, fld_double DOUBLE, fld_bool BOOLEAN, \ fld_str STRING, fld_bin BINARY, fld_time TIMESTAMP(0), fld_num NUMBER, \ fld_json JSON, fld_arr ARRAY(STRING), fld_map MAP(STRING), \ fld_rec RECORD(fld_id LONG, fld_bool BOOLEAN, fld_str STRING), \ PRIMARY KEY(fld_id)) USING TTL 2 DAYS') limits = TableLimits(5000, 5000, 50) create_request = TableRequest().set_statement( create_statement).set_table_limits(limits) cls._result = TestBase.table_request(create_request, State.ACTIVE) index_names.append(list()) for index in range(table + num_indexes): idx_name = index_name + str(index) index_names[table].append(idx_name) create_index_statement = ('CREATE INDEX ' + idx_name + ' ON ' + tb_name + '(' + ','.join(index_fields[index]) + ')') create_index_request = TableRequest().set_statement( create_index_statement) cls._result = TestBase.table_request(create_index_request, State.ACTIVE)
def setUp(self): TestBase.set_up(self) self.handle_config = get_handle_config(tenant_id) index_name = 'idx_' + table_name self.create_tb_statement = ( 'CREATE TABLE ' + table_name + '(fld_id INTEGER, fld_long LONG, \ fld_float FLOAT, fld_double DOUBLE, fld_bool BOOLEAN, fld_str STRING, \ fld_bin BINARY, fld_time TIMESTAMP(4), fld_num NUMBER, fld_json JSON, \ fld_arr ARRAY(STRING), fld_map MAP(STRING), \ fld_rec RECORD(fld_id LONG, fld_bool BOOLEAN, fld_str STRING), \ PRIMARY KEY(fld_id)) USING TTL 30 DAYS') self.create_idx_statement = ( 'CREATE INDEX ' + index_name + ' ON ' + table_name + '(fld_str, fld_double)') self.alter_fld_statement = ( 'ALTER TABLE ' + table_name + '(DROP fld_num)') self.alter_ttl_statement = ( 'ALTER TABLE ' + table_name + ' USING TTL 16 HOURS') self.drop_idx_statement = ( 'DROP INDEX ' + index_name + ' ON ' + table_name) self.drop_tb_statement = ('DROP TABLE IF EXISTS ' + table_name) self.table_request = TableRequest() self.table_limits = TableLimits(5000, 5000, 50)
def setUp(self): TestBase.set_up(self) self.row = { 'fld_id': 1, 'fld_long': 2147483648, 'fld_float': 3.1414999961853027, 'fld_double': 3.1415, 'fld_bool': True, 'fld_str': '{"name": u1, "phone": null}', 'fld_bin': bytearray(pack('>i', 4)), 'fld_time': datetime.now(), 'fld_num': Decimal(5), 'fld_json': { 'a': '1', 'b': None, 'c': '3' }, 'fld_arr': ['a', 'b', 'c'], 'fld_map': { 'a': '1', 'b': '2', 'c': '3' }, 'fld_rec': { 'fld_id': 1, 'fld_bool': False, 'fld_str': None } } self.key = {'fld_id': 1} self.put_request = PutRequest().set_value( self.row).set_table_name(table_name).set_timeout(timeout) self.get_request = GetRequest().set_key( self.key).set_table_name(table_name) self.ttl = TimeToLive.of_hours(24) self.hour_in_milliseconds = 60 * 60 * 1000 self.day_in_milliseconds = 24 * 60 * 60 * 1000
def _publish_survey(self): self.this_directory = os.path.dirname(__file__) xls_path = os.path.join(self.this_directory, "fixtures", "gps", "gps.xls") TestBase._publish_xls_file(self, xls_path)
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance()
def setUp(self): TestBase.setUp(self) self.settings_url = reverse( profile_settings, kwargs={'username': self.user.username})
def tearDown(self): TestBase.tear_down(self)
def setUp(self): TestBase.setUp(self) self.setup_form(allow_sms=False)
def setUp(self): TestBase.setUp(self) self.app = webtest.TestApp(app)
def setUp(self): TestBase.setUp(self) self.product_page = ProductPage(self.driver, self.wait, fresh_load=True)
def setUp(self): TestBase.setUp(self) self._create_user_and_login('bob', 'bob') self._publish_transportation_form() self.url = reverse(formList, kwargs={'username': self.user.username})
def setUp(self): TestBase.setUp(self) self.homepage = Homepage(self.driver, self.wait, fresh_load=True)
def __init__(self, verification_function, *args, **kwargs): self.verification_function = verification_function TestBase.__init__(self, *args, **kwargs)
def setUp(self): TestBase.setUp(self)
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() self.url = reverse(clone_xlsform, kwargs={'username': self.user.username})
def _publish_survey(self): self.this_directory = os.path.dirname(__file__) xls_path = os.path.join( self.this_directory, "fixtures", "gps", "gps.xls") TestBase._publish_xls_file(self, xls_path)