How to use is_parent method in Slash

Best Python code snippet using slash

test_association.py

Source:test_association.py Github

copy

Full Screen

1from c2corg_api.models.association import _get_current_associations, \2 Association, _diff_associations, synchronize_associations3from c2corg_api.models.route import Route, ROUTE_TYPE4from c2corg_api.models.user_profile import UserProfile5from c2corg_api.models.waypoint import Waypoint, WAYPOINT_TYPE6from c2corg_api.tests import BaseTestCase7class TestAssociation(BaseTestCase):8 def setUp(self): # noqa9 BaseTestCase.setUp(self)10 self.waypoint1 = Waypoint(waypoint_type='summit')11 self.waypoint2 = Waypoint(waypoint_type='summit')12 self.route1 = Route(activities=['hiking'])13 self.route2 = Route(activities=['hiking'])14 self.user_profile1 = UserProfile()15 self.user_profile2 = UserProfile()16 self.session.add_all([17 self.waypoint1, self.waypoint2, self.route1, self.route2,18 self.user_profile1, self.user_profile2])19 self.session.flush()20 def _add_test_data_routes(self):21 self.session.add_all([22 Association.create(23 parent_document=self.route1, child_document=self.route2),24 Association.create(25 parent_document=self.waypoint1, child_document=self.route1),26 Association.create(27 parent_document=self.waypoint2, child_document=self.route1),28 ])29 self.session.flush()30 def test_get_current_associations_routes(self):31 self._add_test_data_routes()32 new_associations = {33 'routes': [34 {'document_id': 1, 'is_parent': True}35 ],36 'waypoints': [37 {'document_id': 2, 'is_parent': True}38 ]39 }40 current_associations = _get_current_associations(41 self.route1, new_associations)42 expected_current_associations = {43 'routes': [44 {'document_id': self.route2.document_id, 'is_parent': False}45 ],46 'waypoints': [47 {48 'document_id': self.waypoint1.document_id,49 'is_parent': True50 },51 {52 'document_id': self.waypoint2.document_id,53 'is_parent': True54 }55 ]56 }57 self.assertEqual(current_associations, expected_current_associations)58 def test_get_current_associations_routes_partial(self):59 """ Check that only those types are loaded that are also given in the60 new associations (e.g. waypoints are not loaded in this case because61 the type is not given as input).62 """63 self._add_test_data_routes()64 new_associations = {65 'routes': [66 {'document_id': 1, 'is_parent': True}67 ]68 }69 current_associations = _get_current_associations(70 self.route1, new_associations)71 expected_current_associations = {72 'routes': [73 {'document_id': self.route2.document_id, 'is_parent': False}74 ]75 }76 self.assertEqual(current_associations, expected_current_associations)77 def test_get_current_associations_waypoints(self):78 self.waypoint3 = Waypoint(waypoint_type='summit')79 self.session.add(self.waypoint3)80 self.session.flush()81 self.session.add_all([82 Association.create(83 parent_document=self.waypoint1, child_document=self.waypoint2),84 Association.create(85 parent_document=self.waypoint3, child_document=self.waypoint1),86 Association.create(87 parent_document=self.waypoint1, child_document=self.route1),88 Association.create(89 parent_document=self.waypoint1, child_document=self.route2),90 ])91 self.session.flush()92 new_associations = {93 # routes are ignored94 'routes': [95 {'document_id': 1, 'is_parent': True},96 {'document_id': 2, 'is_parent': True}97 ],98 'waypoints': [99 {'document_id': 3, 'is_parent': True}100 ],101 'waypoint_children': [102 {'document_id': 4, 'is_parent': False}103 ]104 }105 current_associations = _get_current_associations(106 self.waypoint1, new_associations)107 expected_current_associations = {108 'waypoints': [109 {110 'document_id': self.waypoint3.document_id,111 'is_parent': True112 }113 ],114 'waypoint_children': [115 {116 'document_id': self.waypoint2.document_id,117 'is_parent': False118 }119 ]120 }121 self.assertEqual(current_associations, expected_current_associations)122 def test_get_current_associations_waypoints_partial(self):123 self.session.add(Association.create(124 parent_document=self.waypoint1, child_document=self.waypoint2)125 )126 self.session.flush()127 new_associations = {}128 current_associations = _get_current_associations(129 self.waypoint1, new_associations)130 expected_current_associations = {}131 self.assertEqual(current_associations, expected_current_associations)132 def test_diff_associations(self):133 new_associations = {134 'routes': [135 {'document_id': 1, 'is_parent': True},136 {'document_id': 2, 'is_parent': True}137 ],138 'waypoints': [139 {'document_id': 3, 'is_parent': False}140 ]141 }142 current_associations = {143 'routes': [144 {'document_id': 1, 'is_parent': True},145 {'document_id': 4, 'is_parent': True}146 ],147 'waypoints': []148 }149 to_add, to_remove = _diff_associations(150 new_associations, current_associations)151 expected_to_add = [152 {'document_id': 2, 'is_parent': True, 'doc_type': ROUTE_TYPE},153 {'document_id': 3, 'is_parent': False, 'doc_type': WAYPOINT_TYPE}154 ]155 expected_to_remove = [156 {'document_id': 4, 'is_parent': True, 'doc_type': ROUTE_TYPE}157 ]158 self.assertEqual(159 _get_document_ids(to_add),160 _get_document_ids(expected_to_add))161 self.assertEqual(162 _get_document_ids(to_remove),163 _get_document_ids(expected_to_remove))164 def test_synchronize_associations(self):165 self.route3 = Route(activities=['hiking'])166 self.route4 = Route(activities=['hiking'])167 self.session.add_all([self.route3, self.route4])168 self.session.flush()169 self.session.add_all([170 Association.create(171 parent_document=self.route1, child_document=self.route2),172 Association.create(173 parent_document=self.route1, child_document=self.route3)174 ])175 self.session.flush()176 new_associations = {177 'routes': [178 {'document_id': self.route2.document_id, 'is_parent': True},179 {'document_id': self.route4.document_id, 'is_parent': True}180 ],181 'waypoints': [182 {'document_id': self.waypoint1.document_id, 'is_parent': True}183 ]184 }185 synchronize_associations(186 self.route1, new_associations, self.global_userids['contributor'])187 self.assertIsNotNone(self._get_association(self.route1, self.route2))188 self.assertIsNotNone(self._get_association(self.route4, self.route1))189 self.assertIsNone(self._get_association(self.route2, self.route1))190 self.assertIsNone(self._get_association(self.route1, self.route3))191 self.assertIsNotNone(192 self._get_association(self.waypoint1, self.route1))193 def _get_association(self, main_doc, child_doc):194 return self.session.query(Association).get(195 (main_doc.document_id, child_doc.document_id))196def _get_document_ids(docs):...

Full Screen

Full Screen

test_processing.py

Source:test_processing.py Github

copy

Full Screen

1from data import processing2def test_extract_orgs() -> None:3 domain_map = {4 'canada.ca': {5 'organization_name_en': 'Shared Services Canada',6 'organization_name_fr': 'Services partagés Canada',7 'organization_slug': 'shared-services-canada'8 },9 'digital.canada.ca': {10 'organization_name_en': 'Treasury Board of Canada Secretariat',11 'organization_name_fr': 'Secrétariat du Conseil du Trésor du Canada',12 'organization_slug': 'treasury-board-of-canada-secretariat',13 },14 'numerique.canada.ca': {15 'organization_name_en': 'Treasury Board of Canada Secretariat',16 'organization_name_fr': 'Secrétariat du Conseil du Trésor du Canada',17 'organization_slug': 'treasury-board-of-canada-secretariat',18 },19 }20 organizations = processing.extract_orgs(domain_map)21 assert organizations == {22 'shared-services-canada': {23 "name_en": 'Shared Services Canada',24 "name_fr": 'Services partagés Canada',25 "slug": 'shared-services-canada',26 "total_domains": 1,27 },28 'treasury-board-of-canada-secretariat': {29 "name_en": 'Treasury Board of Canada Secretariat',30 "name_fr": 'Secrétariat du Conseil du Trésor du Canada',31 "slug": 'treasury-board-of-canada-secretariat',32 "total_domains": 2,33 }34 }35def test_map_subdomains() -> None:36 owners = {37 'canada.ca': {38 'organization_slug': 'shared-services-canada',39 'organization_name_en': 'Shared Services Canada',40 'organization_name_fr': 'Services partagés Canada',41 }, 'digital.canada.ca': {42 'organization_slug': 'treasury-board-of-canada-secretariat',43 'organization_name_en': 'Treasury Board of Canada Secretariat',44 'organization_name_fr': 'Secrétariat du Conseil du Trésor du Canada',45 }, 'numerique.canada.ca':{46 'organization_slug': 'treasury-board-of-canada-secretariat',47 'organization_name_en': 'Treasury Board of Canada Secretariat',48 'organization_name_fr': 'Secrétariat du Conseil du Trésor du Canada',49 },50 }51 results = {52 'canada.ca': {53 'is_parent': True,54 'is_owner': True,55 },56 'digital.canada.ca': {57 'is_parent': True,58 'is_owner': True,59 },60 'numerique.canada.ca': {61 'is_parent': True,62 'is_owner': True,63 },64 'open.canada.ca': {65 'is_parent': False,66 'is_owner': False,67 },68 'ouvert.canada.ca': {69 'is_parent': False,70 'is_owner': False,71 },72 'somethingdifferent.ca': {73 'is_parent': False,74 'is_owner': False,75 }76 }77 processing.map_subdomains(results, owners)78 assert results == {79 'canada.ca': {80 'base_domain': 'canada.ca',81 'is_parent': True,82 'is_owner': True,83 'organization_slug': 'shared-services-canada',84 'organization_name_en': 'Shared Services Canada',85 'organization_name_fr': 'Services partagés Canada',86 },87 'digital.canada.ca': {88 'base_domain': 'digital.canada.ca',89 'is_parent': True,90 'is_owner': True,91 'organization_slug': 'treasury-board-of-canada-secretariat',92 'organization_name_en': 'Treasury Board of Canada Secretariat',93 'organization_name_fr': 'Secrétariat du Conseil du Trésor du Canada',94 },95 'numerique.canada.ca': {96 'base_domain': 'numerique.canada.ca',97 'is_parent': True,98 'is_owner': True,99 'organization_slug': 'treasury-board-of-canada-secretariat',100 'organization_name_en': 'Treasury Board of Canada Secretariat',101 'organization_name_fr': 'Secrétariat du Conseil du Trésor du Canada',102 },103 'open.canada.ca': {104 'base_domain': 'canada.ca',105 'is_owner': False,106 'is_parent': False,107 'organization_slug': 'shared-services-canada',108 'organization_name_en': 'Shared Services Canada',109 'organization_name_fr': 'Services partagés Canada',110 },111 'ouvert.canada.ca': {112 'base_domain': 'canada.ca',113 'is_owner': False,114 'is_parent': False,115 'organization_slug': 'shared-services-canada',116 'organization_name_en': 'Shared Services Canada',117 'organization_name_fr': 'Services partagés Canada',118 },119 'somethingdifferent.ca': {120 'base_domain': 'somethingdifferent.ca',121 'is_owner': False,122 'is_parent': True,123 'organization_slug': 'government-of-canada',124 'organization_name_en': 'Government of Canada',125 'organization_name_fr': 'Gouvernement du Canada',126 }...

Full Screen

Full Screen

genome_utils_test.py

Source:genome_utils_test.py Github

copy

Full Screen

...38 pass39 def test_user(self):40 self.assertEqual(GenomeInterface.determine_tier('RefSeq user'),41 ('RefSeq', ['ExternalDB', 'User']))42 def test_is_parent(self):43 gene_1 = {"type": "gene", "location": [["A", 100, "+", 400]]}44 gene_2 = {"type": "gene", "location": [["A", 500, "-", 400]]}45 gene_3 = {"type": "gene", "location": [["B", 100, "+", 400]]}46 mrna_1 = {"type": "mRNA", "location": [["A", 100, "+", 50], ["A", 175, "+", 75],47 ["A", 300, "+", 75], ["A", 400, "+", 100]]}48 mrna_2 = {"type": "mRNA", "location": [["A", 500, "-", 50], ["A", 425, "-", 75],49 ["A", 300, "-", 75], ["A", 200, "-", 100]]}50 mrna_3 = {"type": "mRNA", "location": [["B", 100, "+", 100]]}51 cds_1 = {"type": "mRNA", "location": [["A", 100, "+", 50], ["A", 175, "+", 75],52 ["A", 300, "+", 75], ["A", 400, "+", 50]]}53 cds_1a = {"type": "CDS", "location": [["A", 200, "+", 50], ["A", 300, "+", 75],54 ["A", 400, "+", 50]]}55 cds_2 = {"type": "CDS", "location": [["A", 500, "-", 50], ["A", 425, "-", 75],56 ["A", 300, "-", 75], ["A", 200, "-", 50]]}57 cds_2a = {"type": "CDS", "location": [["A", 400, "-", 50], ["A", 300, "-", 75],58 ["A", 200, "-", 50]]}59 cds_3 = {"type": "CDS", "location": [["B", 125, "+", 50]]}60 cds_3a = {"type": "CDS", "location": [["B", 150, "+", 50], ["B", 175, "+", 75],61 ["B", 300, "+", 75], ["B", 400, "+", 50]]}62 cds_4 = {"type": "mRNA", "location": [["A", 100, "+", 50], ["A", 175, "+", 50],63 ["A", 300, "+", 75], ["A", 400, "+", 50]]}64 cds_5 = {"type": "mRNA", "location": [["A", 100, "+", 50], ["A", 400, "+", 50]]}65 # Test gene parentage66 self.assertTrue(GenomeUtils.is_parent(gene_1, mrna_1))67 self.assertTrue(GenomeUtils.is_parent(gene_1, cds_1))68 self.assertTrue(GenomeUtils.is_parent(gene_2, mrna_2))69 self.assertTrue(GenomeUtils.is_parent(gene_2, cds_2))70 self.assertTrue(GenomeUtils.is_parent(gene_3, mrna_3))71 self.assertTrue(GenomeUtils.is_parent(gene_3, cds_3))72 self.assertFalse(GenomeUtils.is_parent(gene_1, mrna_2))73 self.assertFalse(GenomeUtils.is_parent(gene_1, cds_2))74 self.assertFalse(GenomeUtils.is_parent(gene_1, mrna_3))75 self.assertFalse(GenomeUtils.is_parent(gene_1, cds_3))76 # test mrna parentage77 self.assertTrue(GenomeUtils.is_parent(mrna_1, cds_1))78 self.assertTrue(GenomeUtils.is_parent(mrna_1, cds_1a))79 self.assertTrue(GenomeUtils.is_parent(mrna_2, cds_2))80 self.assertTrue(GenomeUtils.is_parent(mrna_2, cds_2a))81 self.assertTrue(GenomeUtils.is_parent(mrna_3, cds_3))82 self.assertFalse(GenomeUtils.is_parent(mrna_1, cds_2))83 self.assertFalse(GenomeUtils.is_parent(mrna_1, cds_3))84 self.assertFalse(GenomeUtils.is_parent(mrna_1, cds_3a))85 self.assertFalse(GenomeUtils.is_parent(mrna_1, cds_4))...

Full Screen

Full Screen

test_customBox.py

Source:test_customBox.py Github

copy

Full Screen

1# -*- encoding: utf-8 -*-2'''3@File : test_customBox.py 4@Contact : fttxtest@163.com5@License : (C)Copyright 2017-2018, Liugroup-NLPR-CASIA6@Modify Time @Author @Version @Desciption7------------ ------- -------- -----------82020/5/18 0018 10:32 dmk 1.0 None9'''10import allure,pytest11from pageObject.customBoxPage.customBoxPage import customBoxPage12addCustomBox_datas = [(1,"新增不重名的一级自定义箱",{"is_parent":1,"is_repeat":0,"expect_toast":"操作成功!"}),(2,"新增重名的一级自定义箱",{"is_parent":1,"is_repeat":1,"expect_toast":"箱子名称已存在"}),(3,"新增不重名的二级自定义箱",{"is_parent":0,"is_repeat":0,"expect_toast":"操作成功!"}),(4,"新增重名的二级自定义箱",{"is_parent":0,"is_repeat":1,"expect_toast":"箱子名称已存在"})]13editCustomBox_datas = [(1,"编辑不重名的一级自定义箱",{"is_parent":1,"is_repeat":0,"expect_toast":"操作成功!"}),(2,"编辑重名的一级自定义箱",{"is_parent":1,"is_repeat":1,"expect_toast":"箱子名称已存在"}),(3,"编辑不重名的二级自定义箱",{"is_parent":0,"is_repeat":0,"expect_toast":"操作成功!"}),(4,"编辑重名的二级自定义箱",{"is_parent":0,"is_repeat":1,"expect_toast":"箱子名称已存在"})]14delCustomBox_datas = [(1,"删除一级自定义箱子",{"is_parent":1,"expect_toast":"删除成功"}),(2,"删除二级自定义箱子",{"is_parent":0,"expect_toast":"删除成功"})]15moveAllEmail_datas = [(1,"移动全部邮件到收件箱",{"boxCategory":"收件箱"}),(2,"移动全部邮件到已发箱",{"boxCategory":"已发箱"}),(3,"移动全部邮件到群发箱",{"boxCategory":"群发箱"}),(4,"移动全部邮件到客户箱",{"boxCategory":"客户箱"}),(5,"移动全部邮件到供应商箱",{"boxCategory":"供应商箱"}),(6,"移动全部邮件到内部联系人箱",{"boxCategory":"内部联系人箱"}),(7,"移动全部邮件到自定义箱",{"boxCategory":"自定义箱"})]16@allure.feature("自定义箱相关功能")17class TestCustomBox:18 @allure.story("新增自定义箱相关功能")19 @pytest.mark.parametrize("caseid,casename,data",addCustomBox_datas)20 def test_addCustomBox(self,caseid,casename,data,login):21 if caseid == 3:22 self.driver = customBoxPage(login)23 self.driver.run_addCustomBox_case(data)24 @allure.story("编辑自定义箱子相关功能")25 @pytest.mark.parametrize("caseid,casename,data",editCustomBox_datas)26 def test_editCustomBox(self,caseid,casename,data,login):27 self.driver = customBoxPage(login)28 self.driver.run_editCustomBox_case(data)29 @allure.story("删除自定义箱子功能")30 @pytest.mark.parametrize("caseid,casename,data",delCustomBox_datas)31 def test_delCustomBox(self,caseid,casename,data,login):32 self.driver = customBoxPage(login)33 self.driver.run_delCustomBox_case(data)34 @allure.story("清空自定义箱子")35 def test_clearCustomBox(self,login):36 self.driver = customBoxPage(login)37 self.driver.run_clearCustomBox_case()38 @allure.story("移到全部邮件相关功能")39 @pytest.mark.parametrize("caseid,casename,data",moveAllEmail_datas)40 def test_moveAllEmail(self,caseid,casename,data,login):41 self.driver = customBoxPage(login)42 self.driver.run_moveAllEmail_case(data)43if __name__ == '__main__':...

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 Slash 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