How to use do_POST method in avocado

Best Python code snippet using avocado_python

1987.py

Source:1987.py Github

copy

Full Screen

1# pylint: disable=E11032"""3Tests for groups module4"""5from dateutil.relativedelta import relativedelta6from random import randint7import uuid8import mock9from urllib import urlencode10from django.conf import settings11from django.core.cache import cache12from django.test.utils import override_settings13from django.utils import timezone14from edx_solutions_api_integration.models import GroupRelationship, GroupProfile15from edx_solutions_organizations.models import Organization16from edx_solutions_projects.models import Project17from edx_solutions_api_integration.test_utils import APIClientMixin18from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory19from xmodule.modulestore.tests.django_utils import (20 ModuleStoreTestCase,21 TEST_DATA_SPLIT_MODULESTORE22)23from student.tests.factories import GroupFactory24@mock.patch.dict("django.conf.settings.FEATURES", {'ENFORCE_PASSWORD_POLICY': False,25 'ADVANCED_SECURITY': False,26 'PREVENT_CONCURRENT_LOGINS': False})27class GroupsApiTests(ModuleStoreTestCase, APIClientMixin):28 """ Test suite for Groups API views """29 MODULESTORE = TEST_DATA_SPLIT_MODULESTORE30 def setUp(self):31 super(GroupsApiTests, self).setUp()32 self.test_username = str(uuid.uuid4())33 self.test_password = str(uuid.uuid4())34 self.test_email = str(uuid.uuid4()) + '@test.org'35 self.test_group_name = str(uuid.uuid4())36 self.test_first_name = str(uuid.uuid4())37 self.test_last_name = str(uuid.uuid4())38 self.base_users_uri = '/api/server/users'39 self.base_groups_uri = '/api/server/groups'40 self.base_workgroups_uri = '/api/server/workgroups/'41 self.test_course_data = '<html>{}</html>'.format(str(uuid.uuid4()))42 self.course = CourseFactory.create()43 self.test_course_id = unicode(self.course.id)44 self.course_end_date = timezone.now() + relativedelta(days=60)45 self.course_content = ItemFactory.create(46 category="videosequence",47 parent_location=self.course.location,48 due=self.course_end_date,49 display_name="View_Sequence"50 )51 self.test_organization = Organization.objects.create(52 name="Test Organization",53 display_name='Test Org',54 contact_name='John Org',55 contact_email='john@test.org',56 contact_phone='+1 332 232 24234'57 )58 self.test_project = Project.objects.create(59 course_id=unicode(self.course.id),60 content_id=unicode(self.course_content.scope_ids.usage_id)61 )62 cache.clear()63 def test_group_list_post(self):64 data = {'name': self.test_group_name, 'type': 'test'}65 response = self.do_post(self.base_groups_uri, data)66 self.assertEqual(response.status_code, 201)67 self.assertGreater(response.data['id'], 0)68 confirm_uri = self.base_groups_uri + '/' + str(response.data['id'])69 self.assertIn(confirm_uri, response.data['uri'])70 self.assertGreater(len(response.data['name']), 0)71 def test_group_list_get_with_profile(self): # pylint: disable=R091572 group_type = 'series'73 display_name = 'My first series'74 profile_data = {'display_name': display_name}75 data = {76 'name': self.test_group_name,77 'type': group_type,78 'data': profile_data79 }80 response = self.do_post(self.base_groups_uri, data)81 self.assertGreater(response.data['id'], 0)82 group_id = response.data['id']83 # query for list of groups, but don't put the type filter84 test_uri = self.base_groups_uri85 response = self.do_get(test_uri)86 self.assertEqual(response.status_code, 400)87 # try again with filter88 test_uri = '{}?type={}'.format(self.base_groups_uri, group_type)89 response = self.do_get(test_uri)90 self.assertEqual(response.status_code, 200)91 self.assertEqual(response.data['count'], 1)92 self.assertEqual(response.data['num_pages'], 1)93 self.assertEqual(len(response.data['results']), 1)94 self.assertEqual(response.data['results'][0]['id'], group_id)95 self.assertEqual(response.data['results'][0]['type'], group_type)96 self.assertEqual(response.data['results'][0]['name'], self.test_group_name)97 response_profile_data = response.data['results'][0]['data']98 self.assertEqual(response_profile_data['display_name'], display_name)99 # query the group detail100 test_uri = '{}/{}'.format(self.base_groups_uri, str(group_id))101 response = self.do_get(test_uri)102 self.assertEqual(response.status_code, 200)103 self.assertEqual(response.data['id'], group_id)104 self.assertIn(test_uri, response.data['uri'])105 self.assertEqual(response.data['name'], self.test_group_name)106 self.assertEqual(response.data['type'], group_type)107 response_profile_data = response.data['data']108 self.assertEqual(response_profile_data['display_name'], display_name)109 # update the profile110 updated_group_type = 'seriesX'111 updated_display_name = 'My updated series'112 profile_data = {'display_name': updated_display_name}113 data = {114 'name': self.test_group_name,115 'type': updated_group_type,116 'data': profile_data117 }118 response = self.do_post(test_uri, data)119 self.assertEqual(response.status_code, 200)120 # requery the filter121 test_uri = self.base_groups_uri + '?type=series'122 response = self.do_get(test_uri)123 self.assertEqual(response.status_code, 200)124 self.assertEqual(len(response.data['results']), 0)125 test_uri = '{}?type={}'.format(self.base_groups_uri, updated_group_type)126 response = self.do_get(test_uri)127 self.assertEqual(response.status_code, 200)128 self.assertEqual(len(response.data['results']), 1)129 self.assertEqual(response.data['results'][0]['id'], group_id)130 self.assertEqual(response.data['results'][0]['type'], updated_group_type)131 self.assertEqual(response.data['results'][0]['name'], self.test_group_name)132 response_profile_data = response.data['results'][0]['data']133 self.assertEqual(response_profile_data['display_name'], updated_display_name)134 def test_group_list_post_invalid_name(self):135 data = {'name': '', 'type': 'test'}136 response = self.do_post(self.base_groups_uri, data)137 self.assertEqual(response.status_code, 400)138 def test_group_list_post_missing_type(self):139 data = {'name': ''}140 response = self.do_post(self.base_groups_uri, data)141 self.assertEqual(response.status_code, 400)142 def test_group_list_get_uses_base_group_name(self):143 data = {'name': self.test_group_name, 'type': 'test'}144 response = self.do_post(self.base_groups_uri, data)145 self.assertEqual(response.status_code, 201)146 group_id = response.data['id']147 profile = GroupProfile.objects.get(group_id=group_id)148 profile.name = ''149 profile.save()150 test_uri = '{}?type=test'.format(self.base_groups_uri)151 response = self.do_get(test_uri)152 self.assertEqual(response.status_code, 200)153 self.assertEqual(response.data['results'][0]['name'], '{:04d}: {}'.format(group_id, self.test_group_name))154 profile.name = None155 profile.save()156 response = self.do_get(test_uri)157 self.assertEqual(response.status_code, 200)158 self.assertEqual(response.data['results'][0]['name'], '{:04d}: {}'.format(group_id, self.test_group_name))159 def test_group_detail_get(self):160 data = {'name': self.test_group_name, 'type': 'test'}161 response = self.do_post(self.base_groups_uri, data)162 self.assertEqual(response.status_code, 201)163 self.assertGreater(response.data['id'], 0)164 group_id = response.data['id']165 test_uri = self.base_groups_uri + '/' + str(group_id)166 response = self.do_get(test_uri)167 self.assertEqual(response.status_code, 200)168 self.assertEqual(response.data['id'], group_id)169 self.assertIn(test_uri, response.data['uri'])170 self.assertEqual(response.data['name'], self.test_group_name)171 def test_group_detail_get_uses_base_group_name(self):172 data = {'name': self.test_group_name, 'type': 'test'}173 response = self.do_post(self.base_groups_uri, data)174 self.assertEqual(response.status_code, 201)175 self.assertGreater(response.data['id'], 0)176 group_id = response.data['id']177 profile = GroupProfile.objects.get(group_id=group_id)178 profile.name = ''179 profile.save()180 test_uri = self.base_groups_uri + '/' + str(group_id)181 response = self.do_get(test_uri)182 self.assertEqual(response.status_code, 200)183 self.assertEqual(response.data['id'], group_id)184 self.assertIn(test_uri, response.data['uri'])185 self.assertEqual(response.data['name'], '{:04d}: {}'.format(group_id, self.test_group_name))186 def test_group_detail_get_with_missing_profile(self):187 data = {'name': self.test_group_name, 'type': 'test'}188 response = self.do_post(self.base_groups_uri, data)189 self.assertEqual(response.status_code, 201)190 self.assertGreater(response.data['id'], 0)191 group_id = response.data['id']192 GroupProfile.objects.get(group_id=group_id).delete()193 test_uri = self.base_groups_uri + '/' + str(group_id)194 response = self.do_get(test_uri)195 self.assertEqual(response.status_code, 200)196 self.assertEqual(response.data['id'], group_id)197 self.assertIn(test_uri, response.data['uri'])198 self.assertEqual(response.data['name'], '{:04d}: {}'.format(group_id, self.test_group_name))199 def test_group_detail_get_undefined(self):200 test_uri = self.base_groups_uri + '/123456789'201 response = self.do_get(test_uri)202 self.assertEqual(response.status_code, 404)203 def test_group_detail_post(self):204 data = {'name': self.test_group_name, 'type': 'test'}205 response = self.do_post(self.base_groups_uri, data)206 group_id = response.data['id']207 test_uri = response.data['uri']208 self.assertEqual(response.status_code, 201)209 group_name = 'Updated Name'210 group_type = 'seriesX'211 data = {212 'name': group_name,213 'type': group_type,214 'data': {215 'display_name': 'My updated series'216 }217 }218 response = self.do_post(test_uri, data)219 self.assertEqual(response.status_code, 200)220 self.assertEqual(response.data['id'], group_id)221 self.assertEqual(response.data['name'], group_name)222 self.assertEqual(response.data['uri'], test_uri)223 def test_group_detail_post_invalid_group(self):224 test_uri = '{}/23209232'.format(self.base_groups_uri)225 group_type = 'seriesX'226 data = {227 'name': self.test_group_name,228 'type': group_type,229 'data': {230 'display_name': 'My updated series'231 }232 }233 response = self.do_post(test_uri, data)234 self.assertEqual(response.status_code, 404)235 def test_group_detail_delete(self):236 local_username = self.test_username + str(randint(11, 99))237 data = {238 'email': self.test_email,239 'username': local_username,240 'password': self.test_password,241 'first_name': 'Joe',242 'last_name': 'Smith'243 }244 response = self.do_post(self.base_users_uri, data)245 user_id = response.data['id']246 data = {'name': self.test_group_name, 'type': 'test'}247 response = self.do_post(self.base_groups_uri, data)248 self.assertEqual(response.status_code, 201)249 self.assertGreater(response.data['id'], 0)250 group_id = response.data['id']251 test_uri = '{}/{}/users'.format(self.base_groups_uri, group_id)252 data = {'user_id': user_id}253 response = self.do_post(test_uri, data)254 self.assertEqual(response.status_code, 201)255 test_uri = '{}/{}'.format(self.base_groups_uri, group_id)256 response = self.do_delete(test_uri)257 self.assertEqual(response.status_code, 204)258 response = self.do_get(test_uri)259 self.assertEqual(response.status_code, 404)260 def test_group_detail_delete_invalid_group(self):261 test_uri = '{}/23209232'.format(self.base_groups_uri)262 response = self.do_delete(test_uri)263 self.assertEqual(response.status_code, 204)264 def test_group_users_list_post(self):265 local_username = self.test_username + str(randint(11, 99))266 data = {267 'email': self.test_email,268 'username': local_username,269 'password': self.test_password,270 'first_name': 'Joe',271 'last_name': 'Smith'272 }273 response = self.do_post(self.base_users_uri, data)274 user_id = response.data['id']275 data = {'name': 'Alpha Group', 'type': 'test'}276 response = self.do_post(self.base_groups_uri, data)277 group_id = response.data['id']278 test_uri = self.base_groups_uri + '/' + str(group_id)279 response = self.do_get(test_uri)280 test_uri = test_uri + '/users'281 data = {'user_id': user_id}282 response = self.do_post(test_uri, data)283 self.assertEqual(response.status_code, 201)284 def test_group_users_list_post_multiple(self):285 user_id = []286 for i in xrange(2):287 local_username = self.test_username + str(i)288 data = {'email': self.test_email, 'username': local_username, 'password': self.test_password}289 response = self.do_post(self.base_users_uri, data)290 user_id.append(response.data['id'])291 data = {'name': 'Alpha Group', 'type': 'test'}292 response = self.do_post(self.base_groups_uri, data)293 test_uri = self.base_groups_uri + '/' + str(response.data['id'])294 response = self.do_get(test_uri)295 test_uri = test_uri + '/users'296 data = {'user_id': ','.join(map(str, user_id))}297 response = self.do_post(test_uri, data)298 self.assertEqual(response.status_code, 201)299 response = self.do_get(test_uri)300 self.assertEqual(len(user_id), len(response.data['users']))301 def test_group_users_list_post_invalid_group(self):302 test_uri = self.base_groups_uri + '/1239878976'303 test_uri = test_uri + '/users'304 data = {'user_id': "98723896"}305 response = self.do_post(test_uri, data)306 self.assertEqual(response.status_code, 404)307 def test_group_users_list_post_invalid_user(self):308 data = {'name': 'Alpha Group', 'type': 'test'}309 response = self.do_post(self.base_groups_uri, data)310 test_uri = '{}/{}/users'.format(self.base_groups_uri, str(response.data['id']))311 data = {'user_id': "98723896"}312 response = self.do_post(test_uri, data)313 self.assertEqual(response.status_code, 404)314 def test_group_users_list_get(self):315 local_username = self.test_username + str(randint(11, 99))316 data = {317 'email': self.test_email,318 'username': local_username,319 'password': self.test_password,320 'first_name': 'Joe',321 'last_name': 'Smith'322 }323 response = self.do_post(self.base_users_uri, data)324 user_id = response.data['id']325 data = {'name': 'Alpha Group', 'type': 'test'}326 response = self.do_post(self.base_groups_uri, data)327 group_id = response.data['id']328 test_uri = self.base_groups_uri + '/' + str(group_id)329 response = self.do_get(test_uri)330 test_uri = test_uri + '/users'331 data = {'user_id': user_id}332 response = self.do_post(test_uri, data)333 self.assertEqual(response.status_code, 201)334 response = self.do_get(test_uri)335 self.assertEqual(response.status_code, 200)336 users = response.data['users']337 self.assertEqual(len(users), 1)338 self.assertEqual(users[0]['id'], user_id)339 self.assertEqual(users[0]['username'], local_username)340 self.assertEqual(users[0]['email'], self.test_email)341 self.assertEqual(users[0]['first_name'], 'Joe')342 self.assertEqual(users[0]['last_name'], 'Smith')343 def test_group_users_list_get_with_is_active_flag(self):344 group_data = {'name': 'Alpha Group', 'type': 'test'}345 response = self.do_post(self.base_groups_uri, group_data)346 group_id = response.data['id']347 is_active = True348 for num in range(0, 5): # pylint: disable=C7620349 if num == 3:350 is_active = False351 data = {352 'email': '{}{}'.format(num, self.test_email),353 'username': '{}{}'.format(num, self.test_username),354 'password': self.test_password,355 'first_name': self.test_first_name,356 'last_name': self.test_last_name,357 'is_active': is_active358 }359 # associating a user with a group360 response = self.do_post(self.base_users_uri, data)361 self.assertEqual(response.status_code, 201)362 user_id = response.data['id']363 test_uri = self.base_groups_uri + '/' + str(group_id) + '/users'364 response = self.do_post(test_uri, data={'user_id': user_id})365 self.assertEqual(response.status_code, 201)366 # getting users without is_active in query params367 response = self.do_get(test_uri)368 self.assertEqual(response.status_code, 200)369 users = response.data['users']370 self.assertEqual(len(users), 5)371 # getting users with is_active=false372 test_uri_inactive_user = test_uri + '/?is_active=false'373 response = self.do_get(test_uri_inactive_user)374 users = response.data['users']375 self.assertEqual(len(users), 2)376 # getting users with is_active=true377 test_uri_active_user = test_uri + '/?is_active=true'378 response = self.do_get(test_uri_active_user)379 self.assertEqual(response.status_code, 200)380 users = response.data['users']381 self.assertEqual(len(users), 3)382 def test_group_users_list_get_invalid_group(self):383 test_uri = self.base_groups_uri + '/1231241/users'384 response = self.do_get(test_uri)385 self.assertEqual(response.status_code, 404)386 def test_group_users_detail_get(self):387 local_username = self.test_username + str(randint(11, 99))388 data = {'email': self.test_email, 'username': local_username, 'password': self.test_password}389 response = self.do_post(self.base_users_uri, data)390 user_id = response.data['id']391 data = {'name': 'Alpha Group', 'type': 'test'}392 response = self.do_post(self.base_groups_uri, data)393 group_id = response.data['id']394 test_uri = self.base_groups_uri + '/' + str(response.data['id'])395 response = self.do_get(test_uri)396 test_uri = test_uri + '/users'397 data = {'user_id': user_id}398 response = self.do_post(test_uri, data)399 test_uri = test_uri + '/' + str(user_id)400 response = self.do_get(test_uri)401 self.assertEqual(response.status_code, 200)402 self.assertGreater(len(response.data['uri']), 0)403 self.assertIn(test_uri, response.data['uri'])404 self.assertEqual(response.data['group_id'], group_id)405 self.assertEqual(response.data['user_id'], user_id)406 def test_group_users_detail_delete(self):407 local_username = self.test_username + str(randint(11, 99))408 data = {'email': self.test_email, 'username': local_username, 'password': self.test_password}409 response = self.do_post(self.base_users_uri, data)410 user_id = response.data['id']411 data = {'name': 'Alpha Group', 'type': 'test'}412 response = self.do_post(self.base_groups_uri, data)413 test_uri = self.base_groups_uri + '/' + str(response.data['id'])414 response = self.do_get(test_uri)415 test_uri = test_uri + '/users'416 data = {'user_id': user_id}417 response = self.do_post(test_uri, data)418 test_uri = test_uri + '/' + str(user_id)419 response = self.do_delete(test_uri)420 self.assertEqual(response.status_code, 204)421 response = self.do_delete(test_uri)422 self.assertEqual(response.status_code, 204) # Idempotent423 response = self.do_get(test_uri)424 self.assertEqual(response.status_code, 404)425 def test_group_users_detail_delete_invalid_group(self):426 test_uri = self.base_groups_uri + '/123987102/users/123124'427 response = self.do_delete(test_uri)428 self.assertEqual(response.status_code, 204)429 def test_group_users_detail_delete_invalid_user(self):430 data = {'name': self.test_group_name, 'type': 'test'}431 response = self.do_post(self.base_groups_uri, data)432 test_uri = self.base_groups_uri + '/' + str(response.data['id'])433 test_uri = test_uri + '/users/123124'434 response = self.do_delete(test_uri)435 self.assertEqual(response.status_code, 204)436 def test_group_users_detail_get_undefined(self):437 local_username = self.test_username + str(randint(11, 99))438 data = {'email': self.test_email, 'username': local_username, 'password': self.test_password}439 response = self.do_post(self.base_users_uri, data)440 user_id = response.data['id']441 data = {'name': 'Alpha Group', 'type': 'test'}442 response = self.do_post(self.base_groups_uri, data)443 group_id = response.data['id']444 test_uri = self.base_groups_uri + '/' + str(group_id) + '/users/' + str(user_id)445 response = self.do_get(test_uri)446 self.assertEqual(response.status_code, 404)447 def test_group_groups_list_post_hierarchical(self):448 data = {'name': 'Alpha Group', 'type': 'test'}449 alpha_response = self.do_post(self.base_groups_uri, data)450 self.assertEqual(alpha_response.status_code, 201)451 data = {'name': 'Beta Group', 'type': 'test'}452 beta_response = self.do_post(self.base_groups_uri, data)453 self.assertEqual(beta_response.status_code, 201)454 data = {'name': 'Delta Group', 'type': 'test'}455 delta_response = self.do_post(self.base_groups_uri, data)456 self.assertEqual(delta_response.status_code, 201)457 test_uri = alpha_response.data['uri'] + '/groups'458 group_id = delta_response.data['id']459 relationship_type = 'h' # Hierarchical460 data = {'group_id': group_id, 'relationship_type': relationship_type}461 response = self.do_post(test_uri, data)462 self.assertEqual(response.status_code, 201)463 self.assertGreater(len(response.data['uri']), 0)464 confirm_uri = test_uri + '/' + str(response.data['group_id'])465 self.assertEqual(response.data['uri'], confirm_uri)466 self.assertEqual(response.data['group_id'], str(group_id))467 self.assertEqual(response.data['relationship_type'], relationship_type)468 def test_group_groups_list_post_linked(self):469 data = {'name': 'Alpha Group', 'type': 'test'}470 alpha_response = self.do_post(self.base_groups_uri, data)471 self.assertEqual(alpha_response.status_code, 201)472 data = {'name': 'Beta Group', 'type': 'test'}473 beta_response = self.do_post(self.base_groups_uri, data)474 self.assertEqual(beta_response.status_code, 201)475 data = {'name': 'Delta Group', 'type': 'test'}476 delta_response = self.do_post(self.base_groups_uri, data)477 self.assertEqual(delta_response.status_code, 201)478 test_uri = alpha_response.data['uri'] + '/groups'479 group_id = delta_response.data['id']480 relationship_type = 'g' # Graph481 data = {'group_id': group_id, 'relationship_type': relationship_type}482 response = self.do_post(test_uri, data)483 self.assertEqual(response.status_code, 201)484 self.assertGreater(len(response.data['uri']), 0)485 confirm_uri = test_uri + '/' + str(response.data['group_id'])486 self.assertEqual(response.data['uri'], confirm_uri)487 self.assertEqual(response.data['group_id'], str(group_id))488 self.assertEqual(response.data['relationship_type'], relationship_type)489 def test_group_groups_list_post_linked_duplicate(self):490 data = {'name': 'Alpha Group', 'type': 'test'}491 alpha_response = self.do_post(self.base_groups_uri, data)492 self.assertEqual(alpha_response.status_code, 201)493 data = {'name': 'Beta Group', 'type': 'test'}494 beta_response = self.do_post(self.base_groups_uri, data)495 self.assertEqual(beta_response.status_code, 201)496 data = {'name': 'Delta Group', 'type': 'test'}497 delta_response = self.do_post(self.base_groups_uri, data)498 self.assertEqual(delta_response.status_code, 201)499 test_uri = alpha_response.data['uri'] + '/groups'500 group_id = delta_response.data['id']501 relationship_type = 'g' # Graph502 data = {'group_id': group_id, 'relationship_type': relationship_type}503 response = self.do_post(test_uri, data)504 self.assertEqual(response.status_code, 201)505 response = self.do_post(test_uri, data)506 # Duplicate responses are idemnotent in this case507 self.assertEqual(response.status_code, 201)508 def test_group_groups_list_post_invalid_group(self):509 test_uri = self.base_groups_uri + '/123098/groups'510 relationship_type = 'g' # Graph511 data = {'group_id': '232987', 'relationship_type': relationship_type}512 response = self.do_post(test_uri, data)513 self.assertEqual(response.status_code, 404)514 def test_group_groups_list_post_invalid_relationship_type(self):515 data = {'name': 'Alpha Group', 'type': 'test'}516 alpha_response = self.do_post(self.base_groups_uri, data)517 self.assertEqual(alpha_response.status_code, 201)518 data = {'name': 'Beta Group', 'type': 'test'}519 beta_response = self.do_post(self.base_groups_uri, data)520 self.assertEqual(beta_response.status_code, 201)521 data = {'name': 'Delta Group', 'type': 'test'}522 delta_response = self.do_post(self.base_groups_uri, data)523 self.assertEqual(delta_response.status_code, 201)524 test_uri = alpha_response.data['uri'] + '/groups'525 group_id = delta_response.data['id']526 relationship_type = "z" # Graph527 data = {'group_id': group_id, 'relationship_type': relationship_type}528 response = self.do_post(test_uri, data)529 self.assertEqual(response.status_code, 406)530 def test_group_groups_list_get(self):531 data = {'name': 'Bravo Group', 'type': 'test'}532 bravo_response = self.do_post(self.base_groups_uri, data)533 self.assertEqual(bravo_response.status_code, 201)534 bravo_group_id = bravo_response.data['id']535 bravo_groups_uri = bravo_response.data['uri'] + '/groups'536 data = {'name': 'Charlie Group', 'type': 'test'}537 charlie_response = self.do_post(self.base_groups_uri, data)538 self.assertEqual(charlie_response.status_code, 201)539 charlie_group_id = charlie_response.data['id']540 relationship_type = 'h' # Hierarchical541 data = {'group_id': charlie_group_id, 'relationship_type': relationship_type}542 response = self.do_post(bravo_groups_uri, data)543 self.assertEqual(response.status_code, 201)544 data = {'name': 'Foxtrot Group', 'type': 'test'}545 foxtrot_response = self.do_post(self.base_groups_uri, data)546 self.assertEqual(foxtrot_response.status_code, 201)547 foxtrot_group_id = foxtrot_response.data['id']548 relationship_type = 'g' # Graph549 data = {'group_id': foxtrot_group_id, 'relationship_type': relationship_type}550 response = self.do_post(bravo_groups_uri, data)551 self.assertEqual(response.status_code, 201)552 data = {'name': 'Tango Group', 'type': 'test'}553 tango_response = self.do_post(self.base_groups_uri, data)554 self.assertEqual(tango_response.status_code, 201)555 tango_group_id = tango_response.data['id']556 tango_uri = tango_response.data['uri']557 data = {'group_id': bravo_group_id, 'relationship_type': relationship_type}558 tango_groups_uri = tango_uri + '/groups'559 response = self.do_post(tango_groups_uri, data)560 self.assertEqual(response.status_code, 201)561 response = self.do_get(bravo_groups_uri)562 self.assertEqual(response.status_code, 200)563 self.assertGreater(len(response.data), 0)564 group_idlist = (charlie_group_id, foxtrot_group_id, tango_group_id)565 relationship_count = 0566 for relationship in response.data:567 relationship_count = relationship_count + 1568 group_id = relationship['id']569 self.assertGreater(group_id, 0)570 self.assertFalse(bravo_group_id == group_id)571 self.assertTrue(relationship['relationship_type'] in ["h", "g"])572 self.assertGreater(len(relationship['uri']), 0)573 self.assertEqual(relationship_count, len(group_idlist))574 def test_group_groups_list_get_with_profile_type(self):575 data = {'name': 'Bravo Group', 'type': 'test'}576 bravo_response = self.do_post(self.base_groups_uri, data)577 self.assertEqual(bravo_response.status_code, 201)578 bravo_group_id = bravo_response.data['id']579 bravo_groups_uri = bravo_response.data['uri'] + '/groups?type=test_group'580 data = {'name': 'Charlie Group', 'type': 'test_group'}581 charlie_response = self.do_post(self.base_groups_uri, data)582 self.assertEqual(charlie_response.status_code, 201)583 charlie_group_id = charlie_response.data['id']584 relationship_type = 'h' # Hierarchical585 data = {'group_id': charlie_group_id, 'relationship_type': relationship_type}586 response = self.do_post(bravo_groups_uri, data)587 self.assertEqual(response.status_code, 201)588 data = {'name': 'Foxtrot Group', 'type': 'test_group'}589 foxtrot_response = self.do_post(self.base_groups_uri, data)590 self.assertEqual(foxtrot_response.status_code, 201)591 foxtrot_group_id = foxtrot_response.data['id']592 relationship_type = 'g' # Graph593 data = {'group_id': foxtrot_group_id, 'relationship_type': relationship_type}594 response = self.do_post(bravo_groups_uri, data)595 self.assertEqual(response.status_code, 201)596 data = {'name': 'Tango Group', 'type': 'test'}597 tango_response = self.do_post(self.base_groups_uri, data)598 self.assertEqual(tango_response.status_code, 201)599 tango_uri = tango_response.data['uri']600 data = {'group_id': bravo_group_id, 'relationship_type': relationship_type}601 tango_groups_uri = tango_uri + '/groups'602 response = self.do_post(tango_groups_uri, data)603 self.assertEqual(response.status_code, 201)604 response = self.do_get(bravo_groups_uri)605 self.assertEqual(response.status_code, 200)606 self.assertGreater(len(response.data), 0)607 group_idlist = (charlie_group_id, foxtrot_group_id)608 relationship_count = 0609 for relationship in response.data:610 relationship_count = relationship_count + 1611 group_id = relationship['id']612 self.assertGreater(group_id, 0)613 self.assertFalse(bravo_group_id == group_id)614 self.assertTrue(relationship['relationship_type'] in ["h", "g"])615 self.assertGreater(len(relationship['uri']), 0)616 self.assertEqual(relationship_count, len(group_idlist))617 def test_group_groups_list_get_notfound(self):618 test_uri = self.base_groups_uri + '/213213123/groups'619 response = self.do_get(test_uri)620 self.assertEqual(response.status_code, 404)621 def test_group_groups_detail_get_hierarchical(self):622 data = {'name': 'Alpha Group', 'type': 'test'}623 alpha_response = self.do_post(self.base_groups_uri, data)624 alpha_group_id = alpha_response.data['id']625 self.assertEqual(alpha_response.status_code, 201)626 data = {'name': 'Beta Group', 'type': 'test'}627 beta_response = self.do_post(self.base_groups_uri, data)628 self.assertEqual(beta_response.status_code, 201)629 data = {'name': 'Delta Group', 'type': 'test'}630 delta_response = self.do_post(self.base_groups_uri, data)631 self.assertEqual(delta_response.status_code, 201)632 test_uri = alpha_response.data['uri'] + '/groups'633 delta_group_id = delta_response.data['id']634 relationship_type = 'h' # Hierarchical635 data = {'group_id': delta_group_id, 'relationship_type': relationship_type}636 response = self.do_post(test_uri, data)637 self.assertEqual(response.status_code, 201)638 test_uri = response.data['uri']639 response = self.do_get(test_uri)640 self.assertEqual(response.status_code, 200)641 self.assertGreater(len(response.data['uri']), 0)642 self.assertEqual(response.data['uri'], test_uri)643 self.assertEqual(response.data['from_group_id'], str(alpha_group_id))644 self.assertEqual(response.data['to_group_id'], str(delta_group_id))645 self.assertEqual(response.data['relationship_type'], relationship_type)646 def test_group_groups_detail_get_linked(self):647 data = {'name': 'Alpha Group', 'type': 'test'}648 alpha_response = self.do_post(self.base_groups_uri, data)649 alpha_group_id = alpha_response.data['id']650 self.assertEqual(alpha_response.status_code, 201)651 data = {'name': 'Beta Group', 'type': 'test'}652 beta_response = self.do_post(self.base_groups_uri, data)653 self.assertEqual(beta_response.status_code, 201)654 data = {'name': 'Delta Group', 'type': 'test'}655 delta_response = self.do_post(self.base_groups_uri, data)656 delta_group_id = delta_response.data['id']657 self.assertEqual(delta_response.status_code, 201)658 test_uri = alpha_response.data['uri'] + '/groups'659 relationship_type = 'g' # Graph660 data = {'group_id': delta_group_id, 'relationship_type': relationship_type}661 delta_group = GroupRelationship.objects.get(group_id=delta_group_id)662 delta_group.parent_group_id = None663 delta_group.save()664 response = self.do_post(test_uri, data)665 self.assertEqual(response.status_code, 201)666 test_uri = response.data['uri']667 response = self.do_get(test_uri)668 self.assertEqual(response.status_code, 200)669 self.assertGreater(len(response.data['uri']), 0)670 self.assertEqual(response.data['uri'], test_uri)671 self.assertEqual(response.data['from_group_id'], str(alpha_group_id))672 self.assertEqual(response.data['to_group_id'], str(delta_group_id))673 self.assertEqual(response.data['relationship_type'], relationship_type)674 def test_group_groups_detail_get_notfound(self):675 data = {'name': 'Alpha Group', 'type': 'test'}676 alpha_response = self.do_post(self.base_groups_uri, data)677 self.assertEqual(alpha_response.status_code, 201)678 test_uri = alpha_response.data['uri'] + '/groups/1234'679 response = self.do_get(test_uri)680 self.assertEqual(response.status_code, 404)681 def test_group_groups_detail_delete_hierarchical(self):682 data = {'name': 'Alpha Group', 'type': 'test'}683 alpha_response = self.do_post(self.base_groups_uri, data)684 self.assertEqual(alpha_response.status_code, 201)685 data = {'name': 'Beta Group', 'type': 'test'}686 beta_response = self.do_post(self.base_groups_uri, data)687 self.assertEqual(beta_response.status_code, 201)688 data = {'name': 'Delta Group', 'type': 'test'}689 delta_response = self.do_post(self.base_groups_uri, data)690 self.assertEqual(delta_response.status_code, 201)691 data = {'name': 'Gamma Group', 'type': 'test'}692 gamma_response = self.do_post(self.base_groups_uri, data)693 self.assertEqual(gamma_response.status_code, 201)694 test_uri = alpha_response.data['uri'] + '/groups'695 group_id = gamma_response.data['id']696 relationship_type = 'h'697 data = {'group_id': group_id, 'relationship_type': relationship_type}698 response = self.do_post(test_uri, data)699 self.assertEqual(response.status_code, 201)700 test_uri = response.data['uri']701 response = self.do_delete(test_uri)702 self.assertEqual(response.status_code, 204)703 response = self.do_delete(test_uri)704 self.assertEqual(response.status_code, 204)705 try:706 self.assertIsNone(response.data['message'])707 except KeyError:708 pass709 response = self.do_get(test_uri)710 self.assertEqual(response.status_code, 404)711 def test_group_groups_detail_delete_linked(self):712 data = {'name': 'Alpha Group', 'type': 'test'}713 alpha_response = self.do_post(self.base_groups_uri, data)714 self.assertEqual(alpha_response.status_code, 201)715 data = {'name': 'Beta Group', 'type': 'test'}716 beta_response = self.do_post(self.base_groups_uri, data)717 self.assertEqual(beta_response.status_code, 201)718 data = {'name': 'Delta Group', 'type': 'test'}719 delta_response = self.do_post(self.base_groups_uri, data)720 self.assertEqual(delta_response.status_code, 201)721 data = {'name': 'Gamma Group', 'type': 'test'}722 gamma_response = self.do_post(self.base_groups_uri, data)723 self.assertEqual(gamma_response.status_code, 201)724 test_uri = alpha_response.data['uri'] + '/groups'725 group_id = gamma_response.data['id']726 relationship_type = 'g'727 data = {'group_id': group_id, 'relationship_type': relationship_type}728 response = self.do_post(test_uri, data)729 self.assertEqual(response.status_code, 201)730 test_uri = response.data['uri']731 response = self.do_delete(test_uri)732 self.assertEqual(response.status_code, 204)733 try:734 self.assertIsNone(response.data['message'])735 except KeyError:736 pass737 response = self.do_get(test_uri)738 self.assertEqual(response.status_code, 404)739 def test_group_groups_detail_delete_invalid(self):740 test_uri = self.base_groups_uri + '/1231234232/groups/1'741 response = self.do_delete(test_uri)742 self.assertEqual(response.status_code, 404)743 def test_group_courses_list_post(self):744 data = {'name': self.test_group_name, 'type': 'test'}745 response = self.do_post(self.base_groups_uri, data)746 self.assertEqual(response.status_code, 201)747 group_id = response.data['id']748 test_uri = response.data['uri'] + '/courses'749 data = {'course_id': self.test_course_id}750 response = self.do_post(test_uri, data)751 self.assertEqual(response.status_code, 201)752 confirm_uri = test_uri + '/' + unicode(self.course.id)753 self.assertEqual(response.data['uri'], confirm_uri)754 self.assertEqual(response.data['group_id'], str(group_id))755 self.assertEqual(response.data['course_id'], self.test_course_id)756 def test_group_courses_list_post_duplicate(self):757 data = {'name': self.test_group_name, 'type': 'test'}758 response = self.do_post(self.base_groups_uri, data)759 self.assertEqual(response.status_code, 201)760 test_uri = response.data['uri'] + '/courses'761 data = {'course_id': self.test_course_id}762 response = self.do_post(test_uri, data)763 self.assertEqual(response.status_code, 201)764 response = self.do_post(test_uri, data)765 self.assertEqual(response.status_code, 409)766 def test_group_courses_list_post_invalid_group(self):767 test_uri = self.base_groups_uri + '/1239878976/courses'768 data = {'course_id': "98723896"}769 response = self.do_post(test_uri, data)770 self.assertEqual(response.status_code, 404)771 def test_group_courses_list_post_invalid_course(self):772 data = {'name': self.test_group_name, 'type': 'test'}773 response = self.do_post(self.base_groups_uri, data)774 self.assertEqual(response.status_code, 201)775 test_uri = response.data['uri'] + '/courses'776 data = {'course_id': "invalid/course/id"}777 response = self.do_post(test_uri, data)778 self.assertEqual(response.status_code, 404)779 data = {'course_id': "really-invalid-course-id"}780 response = self.do_post(test_uri, data)781 self.assertEqual(response.status_code, 404)782 def test_group_courses_list_get(self):783 data = {'name': self.test_group_name, 'type': 'test'}784 response = self.do_post(self.base_groups_uri, data)785 self.assertEqual(response.status_code, 201)786 group_id = response.data['id']787 test_uri = response.data['uri'] + '/courses'788 data = {'course_id': self.test_course_id}789 response = self.do_post(test_uri, data)790 self.assertEqual(response.status_code, 201)791 confirm_uri = test_uri + '/' + unicode(self.course.id)792 self.assertEqual(response.data['uri'], confirm_uri)793 self.assertEqual(response.data['group_id'], str(group_id))794 self.assertEqual(response.data['course_id'], self.test_course_id)795 response = self.do_get(test_uri)796 self.assertEqual(response.status_code, 200)797 self.assertEqual(len(response.data), 1)798 self.assertEqual(response.data[0]['course_id'], self.test_course_id)799 self.assertEqual(response.data[0]['display_name'], self.course.display_name)800 def test_group_courses_list_get_invalid_group(self):801 test_uri = self.base_groups_uri + '/1231241/courses'802 response = self.do_get(test_uri)803 self.assertEqual(response.status_code, 404)804 def test_group_courses_detail_get(self):805 data = {'name': self.test_group_name, 'type': 'test'}806 response = self.do_post(self.base_groups_uri, data)807 self.assertEqual(response.status_code, 201)808 group_id = response.data['id']809 test_uri = response.data['uri'] + '/courses'810 data = {'course_id': self.test_course_id}811 response = self.do_post(test_uri, data)812 self.assertEqual(response.status_code, 201)813 test_uri = '{}/{}/courses/{}'.format(self.base_groups_uri, group_id, self.test_course_id)814 response = self.do_get(test_uri)815 self.assertEqual(response.status_code, 200)816 confirm_uri = '{}/{}/courses/{}'.format(817 self.base_groups_uri,818 group_id,819 self.test_course_id820 )821 self.assertIn(confirm_uri, response.data['uri'])822 self.assertEqual(response.data['group_id'], group_id)823 self.assertEqual(response.data['course_id'], self.test_course_id)824 def test_group_courses_detail_delete(self):825 data = {'name': self.test_group_name, 'type': 'test'}826 response = self.do_post(self.base_groups_uri, data)827 self.assertEqual(response.status_code, 201)828 test_uri = response.data['uri'] + '/courses'829 data = {'course_id': self.test_course_id}830 response = self.do_post(test_uri, data)831 self.assertEqual(response.status_code, 201)832 test_uri = response.data['uri']833 response = self.do_delete(test_uri)834 self.assertEqual(response.status_code, 204)835 response = self.do_delete(test_uri)836 self.assertEqual(response.status_code, 204) # Idempotent837 response = self.do_get(test_uri)838 self.assertEqual(response.status_code, 404)839 def test_group_courses_detail_delete_invalid_group(self):840 test_uri = self.base_groups_uri + '/123987102/courses/org.invalid/course_000/Run_000'841 response = self.do_delete(test_uri)842 self.assertEqual(response.status_code, 204)843 def test_group_courses_detail_delete_invalid_course(self):844 data = {'name': self.test_group_name, 'type': 'test'}845 response = self.do_post(self.base_groups_uri, data)846 self.assertEqual(response.status_code, 201)847 test_uri = response.data['uri'] + '/courses/org.invalid/course_000/Run_000'848 response = self.do_delete(test_uri)849 self.assertEqual(response.status_code, 204)850 def test_group_courses_detail_get_undefined(self):851 data = {'name': self.test_group_name, 'type': 'test'}852 response = self.do_post(self.base_groups_uri, data)853 self.assertEqual(response.status_code, 201)854 test_uri = '{}/courses/{}'.format(response.data['uri'], unicode(self.course.id))855 response = self.do_get(test_uri)856 self.assertEqual(response.status_code, 404)857 def test_group_organizations_list_get(self):858 data = {'name': self.test_group_name, 'type': 'test'}859 response = self.do_post(self.base_groups_uri, data)860 self.assertEqual(response.status_code, 201)861 group_id = response.data['id']862 self.test_organization.groups.add(group_id)863 test_uri = response.data['uri'] + '/organizations/'864 response = self.do_get(test_uri)865 self.assertEqual(response.status_code, 200)866 self.assertEqual(len(response.data), 1)867 self.assertEqual(response.data[0]['id'], self.test_organization.id)868 self.assertEqual(response.data[0]['name'], self.test_organization.name)869 def test_group_organizations_list_get_invalid_group(self):870 test_uri = self.base_groups_uri + '/1231241/organizations/'871 response = self.do_get(test_uri)872 self.assertEqual(response.status_code, 404)873 def test_groups_workgroups_list(self):874 data = {'name': self.test_group_name, 'type': 'test'}875 response = self.do_post(self.base_groups_uri, data)876 self.assertEqual(response.status_code, 201)877 group_id = response.data['id']878 test_workgroups_uri = self.base_workgroups_uri879 for i in xrange(1, 12):880 project_id = self.test_project.id881 data = {882 'name': 'Workgroup ' + str(i),883 'project': project_id884 }885 response = self.do_post(test_workgroups_uri, data)886 self.assertEqual(response.status_code, 201)887 test_uri = '{}{}/'.format(test_workgroups_uri, str(response.data['id']))888 users_uri = '{}groups/'.format(test_uri)889 data = {"id": group_id}890 response = self.do_post(users_uri, data)891 self.assertEqual(response.status_code, 201)892 # test to get list of workgroups893 test_uri = '{}/{}/workgroups/?page_size=10'.format(self.base_groups_uri, group_id)894 response = self.do_get(test_uri)895 self.assertEqual(response.data['count'], 11)896 self.assertEqual(len(response.data['results']), 10)897 self.assertEqual(response.data['num_pages'], 2)898 # test with course_id filter899 course_id = {'course_id': unicode(self.course.id)}900 groups_uri = '{}/{}/workgroups/?{}'.format(self.base_groups_uri, group_id, urlencode(course_id))901 response = self.do_get(groups_uri)902 self.assertEqual(response.status_code, 200)903 self.assertEqual(response.data['count'], 11)904 self.assertIsNotNone(response.data['results'][0]['name'])905 self.assertIsNotNone(response.data['results'][0]['project'])906 # test with invalid group id907 response = self.do_get('{}/4356340/workgroups/'.format(self.base_groups_uri))908 self.assertEqual(response.status_code, 404)909 def test_groups_users_list_missing_user_id(self):910 # Create a test group911 group = GroupFactory.create()912 # Test with user_id missing in request data913 test_uri = '{}/{}/users/'.format(self.base_groups_uri, group.id)914 response = self.do_post(test_uri, {})915 self.assertEqual(response.status_code, 400)916 def test_groups_groups_list_missing_group_id(self):917 # Create test group918 from_group = GroupFactory.create()919 # Test with missing group_id in the request data920 test_uri = '{}/{}/groups/'.format(self.base_groups_uri, from_group.id)921 response = self.do_post(test_uri, {})922 self.assertEqual(response.status_code, 400)923 def test_groups_groups_list_missing_relationship_type(self):924 # Create test groups925 from_group = GroupFactory.create()926 to_group = GroupFactory.create()927 # Test with missing relationship_type in the request data928 test_uri = '{}/{}/groups/'.format(self.base_groups_uri, from_group.id)929 response = self.do_post(test_uri, {"group_id": to_group.id})930 self.assertEqual(response.status_code, 400)931 def test_groups_groups_detail_invalid_group_id(self):932 related_group = GroupFactory.create()933 # Test with invalid from_group934 test_uri = '{}/{}/groups/{}'.format(self.base_groups_uri, '1234567', related_group.id)935 response = self.do_get(test_uri)936 self.assertEqual(response.status_code, 404)937 def test_groups_courses_list_missing_course_id(self):938 # Create test group939 test_group = GroupFactory.create()940 # Test with missing course_id in the request data941 test_uri = '{}/{}/courses/'.format(self.base_groups_uri, test_group.id)942 data = {"course_id": ""}943 response = self.do_post(test_uri, data)...

Full Screen

Full Screen

misc.py

Source:misc.py Github

copy

Full Screen

...22 self._last_member = None23 @commands.command()24 async def Lshort(self, ctx, msg):25 ser.do_GET("lshort")26 ser.do_POST() == lshortread27 if lshortread == 1:28 await ctx.send(f"Sent!")29 while lshortread == 1:30 ser.do_POST() == lshortread31 await ctx.send(f"Done!")32 33 @commands.command()34 async def Mshort(self, ctx, msg):35 ser.do_GET("mshort")36 ser.do_POST() == mshortread37 if mshortread == 1:38 await ctx.send(f"Sent!")39 while mshortread == 1:40 ser.do_POST() == mshortread41 await ctx.send(f"Done!")42 43 @commands.command()44 async def Hshort(self, ctx, msg):45 ser.do_GET("hshort")46 ser.do_POST() == hshortread47 if hshortread == 1:48 await ctx.send(f"Sent!")49 while hshortread == 1:50 ser.do_POST() == hshortread51 await ctx.send(f"Done!")52 @commands.command()53 async def llong(self, ctx, msg):54 ser.do_GET("llong")55 ser.do_POST() == llongread56 if llongread == 1:57 await ctx.send(f"Sent!")58 while llongread == 1:59 ser.do_POST() == llongread60 await ctx.send(f"Done!")61 62 @commands.command()63 async def mlong(self, ctx, msg):64 ser.do_GET("mlong")65 ser.do_POST() == mlongread66 if mlongread == 1:67 await ctx.send(f"Sent!")68 while mlongread == 1:69 ser.do_POST() == mlongread70 await ctx.send(f"Done!")71 72 @commands.command()73 async def hlong(self, ctx, msg):74 ser.do_GET("hlong")75 ser.do_POST() == hlongread76 if hlongread == 1:77 await ctx.send(f"Sent!")78 while hlongread == 1:79 ser.do_POST() == hlongread80 await ctx.send(f"Done!") 81 82 @commands.command()83 async def lmedium(self, ctx):84 ser.do_GET("lmed")85 ser.do_POST() == lmedread86 if lmedread == 1:87 await ctx.send(f"Sent!")88 while lmedread == 1:89 ser.do_POST() == lmedread90 await ctx.send(f"Done!")91 92 @commands.command()93 async def mmedium(self, ctx):94 ser.do_GET("mmed")95 ser.do_POST() == mmedread96 if mmedread == 1:97 await ctx.send(f"Sent!")98 while mmedread == 1:99 ser.do_POST() == mmedread100 await ctx.send(f"Done!")101 102 @commands.command()103 async def hmedium(self, ctx):104 ser.do_GET("hmed")105 ser.do_POST() == hmedread106 if hmedread == 1:107 await ctx.send(f"Sent!")108 while hmedread == 1:109 ser.do_POST() == hmedread110 await ctx.send(f"Done!")111def setup(bot):...

Full Screen

Full Screen

hebrewMorph.py

Source:hebrewMorph.py Github

copy

Full Screen

1# coding=utf-82import urllib23import urllib4import codecs5import os6import sys7def do_post(text):8 # This is the URL where the Morphological analyzer web service is running9 url = "http://www.cs.bgu.ac.il/~cohenrap/hebmed/"10 #params = urllib.urlencode({'mytext':text.encode("cp1255"),"output":"plain"})11 params = urllib.urlencode({'mytext':text, 'output':'plain'})12 request = urllib2.Request(url, params)13 response = urllib2.urlopen(request)14 return response.read()15"""----------------------EXAMPLE-------------------------"""16if __name__ == '__main__':17 # print do_post("\u05db\u05d5\u05d0\u05d1 \u05dc\u05d9 \u05d4\u05e8\u05d0\u05e9. \u05de\u05ea\u05d9 \u05e0\u05d2\u05de\u05e8\u05ea \u05d4\u05de\u05e2\u05d1\u05d3\u05d4?")18 # Given a unicode string (encoded in utf-8) get back analysis19 # and print result in a utf-8 file.20 # For example, the BguCorpusReader returns Hebrew strings encoded21 # as utf-8 Python unicode strings.22 f = codecs.open("result.txt", "w", encoding="utf-8")23 w = u'\u05d4\u05d7\u05d3\u05e9\u05d4' # Ha-hadasha as a unicode string24 a = w.encode("utf-8") # Ha-hadasha as an array25 analysis = do_post(a)26 Uanalysis = analysis.decode("utf-8")27 f.write(Uanalysis)28 f.close()29 print analysis30 # analysis = do_post(u"בעיר".encode("utf-8"))31 # print analysis32 #33 # analysis = do_post(u"הילד".encode("utf-8"))34 # print analysis35 #36 # analysis = do_post(u"והלכנו".encode("utf-8"))37 # print analysis38 #39 # analysis = do_post(u"כשלג".encode("utf-8"))40 # print analysis41 #42 # analysis = do_post(u"לים".encode("utf-8"))43 # print analysis44 #45 # analysis = do_post(u"ממקום".encode("utf-8"))46 # print analysis47 #48 # analysis = do_post(u"כשאמר".encode("utf-8"))49 # print analysis50 #51 # analysis = do_post(u"משהלך".encode("utf-8"))52 # print analysis53 #54 # analysis = do_post(u"לכשהלך".encode("utf-8"))55 # print analysis56 #57 # analysis = do_post(u"בכשבדק".encode("utf-8"))58 # print analysis59 #60 # analysis = do_post(u"מכשהלך".encode("utf-8"))61 # print analysis62 #63 # analysis = do_post(u"וכשאבקש".encode("utf-8"))64 # print analysis65 #66 # analysis = do_post(u"וגלידה".encode("utf-8"))67 # print analysis68 #69 # analysis = do_post(u"מבתוך".encode("utf-8"))70 # print analysis71 analysis = do_post(u"במשק".encode("utf-8"))72 print analysis73 analysis = do_post(u"שהרפורמה".encode("utf-8"))74 print analysis75PREFIXES = {76 'DEF': [u'ה'],77 'PREPOSITION': [u'ב',u'כ', u'ל', u'מ', u'מכש' u'מב', u'בכש'],78 'CONJ': [u'ו'],79 'TEMP-SUBCONJ': [u'כש',u'מש', u'לכש'],80 'REL-SUBCONJ': [u'ש']81}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful