How to use str2bool method in ATX

Best Python code snippet using ATX

update_partners.py

Source:update_partners.py Github

copy

Full Screen

2from salesforce.models import Partner, PartnerFieldNameMapping3from salesforce.salesforce import Salesforce4class Command(BaseCommand):5 help = "update partners from salesforce.com for use on the marketplace"6 def str2bool(self, v):7 if isinstance(v, bool):8 return v9 elif isinstance(v, str):10 return v.lower() == "true"11 else:12 return False13 def handle(self, *args, **options):14 with Salesforce() as sf:15 query = "SELECT " \16 "Id, " \17 "Name, " \18 "Partner_Type__c, " \19 "Books_Offered__c, " \20 "Description__c, " \21 "Rich_Description__c, " \22 "short_partner_description__c, " \23 "Website__c, " \24 "Lead_Sharing__c, " \25 "Verified_by_instructors__c, " \26 "Integrated_with_OpenStax_content__c, " \27 "Landing_page__c, " \28 "Account__c, " \29 "Affordability_Cost__c, " \30 "Affordability_institutional__c, " \31 "App_available__c, " \32 "Adaptivity_adaptive_presentation__c, " \33 "Adaptivity_affective_state__c, " \34 "Adaptivity_breadth_and_depth__c, " \35 "Adaptivity_customized_path__c, " \36 "Adaptivity_instructor_control__c, " \37 "Adaptivity_quantitative_randomization__c, " \38 "Adaptivity_varied_level__c, " \39 "Admin_calendar_links__c, " \40 "admin_online_submission__c, " \41 "Admin_realtime_progress__c, " \42 "Admin_shared_students__c, " \43 "Admin_syllabus__c, " \44 "Assignment_outside_resources__c, " \45 "Assignment_editing__c, " \46 "Assignment_multimedia__c, " \47 "Assignment_multiple_quantitative__c, " \48 "Assignment_pretest__c, " \49 "Assignment_scientific_structures__c," \50 "Assignment_summative_assessments__c, " \51 "Autonomy_digital_badges__c, " \52 "Autonomy_on_demand_extras__c, " \53 "Autonomy_self_reflection__c, " \54 "Autonomy_summative_assessments__c, " \55 "Collaboration_peer_feedback__c, " \56 "Collaboration_peer_interaction__c, " \57 "Collaboration_teacher_learner_contact__c, " \58 "Collaboration_tutor__c, " \59 "Content_batch_uploads__c, " \60 "Content_resource_sharing__c, " \61 "Content_sharing_among_courses__c, " \62 "Customization_assessment_repository__c, " \63 "Customization_create_learning_outcomes__c, " \64 "Customization_content_repository__c, " \65 "Customization_reorder_content__c, " \66 "Customization_reorder_learning_outcomes__c, " \67 "Feedback_early_warning__c, " \68 "Feedback_individual_and_group__c, " \69 "Feedback_knowledge_gaps__c, " \70 "Feedback_learner_progress_tasks__c, " \71 "Feedback_multipart__c, " \72 "Feedback_understanding__c, " \73 "Grading_change_scores__c, " \74 "Grading_class_and_student_level__c, " \75 "Grading_group_work__c, " \76 "Grading_learning_portfolio__c, " \77 "Grading_rubric_based__c, " \78 "Grading_tolerances_sig_fig__c, " \79 "Instructional_level_higher_ed__c, " \80 "Interactivity_annotate__c, " \81 "Interactivity_different_representations__c, " \82 "Interactivity_gaming__c, " \83 "Interactivity_previous_knowledge__c, " \84 "Interactivity_simulations__c, " \85 "Interactivity_varying_means__c, " \86 "LMS_analytics__c, " \87 "LMS_sends_grades__c, " \88 "LMS_SSO__c, " \89 "Measure_alternate_assessment__c, " \90 "Measure_assessments_in_most__c, " \91 "Measure_mapping__c, " \92 "Reporting_competency__c, " \93 "Reporting_student_workload__c, " \94 "Scaffolding_hints__c, " \95 "Scaffolding_learner_explanations__c, " \96 "Scaffolding_mental_practice__c, " \97 "Scaffolding_narrative__c, " \98 "Scaffolding_social_intervention__c, " \99 "Usability_design_orients_users__c, " \100 "Usability_glossary__c, " \101 "Usability_partial_progress__c, " \102 "Accessibility_language_UI__c, " \103 "Accessibility_language_content__c, " \104 "Accessibility_VPAT__c, " \105 "Accessibility_WCAG__c, " \106 "Accessibility_Universal_Design__c, " \107 "Instructional_level_K12__c, " \108 "Online_teaching_peer_discussion__c, " \109 "Online_teaching_lecture_streaming__c, " \110 "Online_teaching_in_lecture__c, " \111 "Online_teaching_asynchronous__c, " \112 "Online_teaching_audio_video__c, " \113 "Online_teaching_academic_integrity__c, " \114 "Online_teaching_labs__c, " \115 "International__c, " \116 "Partnership_Level__c, " \117 "Equity_Rating__c " \118 "FROM Partner__c"119 response = sf.query_all(query)120 sf_marketplace_partners = response['records']121 updated_partners = 0122 created_partners = 0123 partner_ids = []124 for partner in sf_marketplace_partners:125 partner_ids.append(partner['Id'])126 if partner['Affordability_Cost__c']:127 affordability_cost=partner['Affordability_Cost__c'].replace(";", "; ")128 else:129 affordability_cost=None130 p, created = Partner.objects.get_or_create(salesforce_id=partner['Id'])131 p.partner_name=partner['Name']132 p.partner_type=partner['Partner_Type__c']133 p.books=partner['Books_Offered__c']134 p.rich_description=partner['Rich_Description__c']135 p.partner_description=partner['Description__c']136 p.short_partner_description=partner['short_partner_description__c']137 p.partner_website=partner['Website__c']138 p.lead_sharing=self.str2bool(partner['Lead_Sharing__c'])139 p.landing_page=partner['Landing_page__c']140 p.verified_by_instructor=self.str2bool(partner['Verified_by_instructors__c'])141 p.integrated=partner['Integrated_with_OpenStax_content__c']142 p.partner_sf_account_id=partner['Account__c']143 p.affordability_cost=affordability_cost144 p.affordability_institutional=self.str2bool(partner['Affordability_Institutional__c'])145 p.app_available=self.str2bool(partner['App_available__c'])146 p.adaptivity_adaptive_presentation=self.str2bool(partner['Adaptivity_adaptive_presentation__c'])147 p.adaptivity_affective_state=self.str2bool(partner['Adaptivity_affective_state__c'])148 p.adaptivity_breadth_and_depth=self.str2bool(partner['Adaptivity_breadth_and_depth__c'])149 p.adaptivity_customized_path=self.str2bool(partner['Adaptivity_customized_path__c'])150 p.adaptivity_instructor_control=self.str2bool(partner['Adaptivity_instructor_control__c'])151 p.adaptivity_quantitative_randomization=self.str2bool(partner['Adaptivity_quantitative_randomization__c'])152 p.adaptivity_varied_level=self.str2bool(partner['Adaptivity_varied_level__c'])153 p.admin_calendar_links=self.str2bool(partner['Admin_calendar_links__c'])154 p.admin_online_submission=self.str2bool(partner['admin_online_submission__c'])155 p.admin_realtime_progress=self.str2bool(partner['Admin_realtime_progress__c'])156 p.admin_shared_students=self.str2bool(partner['Admin_shared_students__c'])157 p.admin_syllabus=self.str2bool(partner['Admin_Syllabus__c'])158 p.assigment_outside_resources=self.str2bool(partner['Assignment_outside_resources__c'])159 p.assignment_editing=self.str2bool(partner['Assignment_editing__c'])160 p.assignment_multimedia=self.str2bool(partner['Assignment_multimedia__c'])161 p.assignment_multiple_quantitative=self.str2bool(partner['Assignment_multiple_quantitative__c'])162 p.assignment_pretest=self.str2bool(partner['Assignment_pretest__c'])163 p.assignment_scientific_structures=self.str2bool(partner['Assignment_scientific_structures__c'])164 p.assignment_summative_assessments=self.str2bool(partner['Assignment_summative_assessments__c'])165 p.autonomy_digital_badges=self.str2bool(partner['Autonomy_digital_badges__c'])166 p.autonomy_on_demand_extras=self.str2bool(partner['Autonomy_on_demand_extras__c'])167 p.autonomy_self_reflection=self.str2bool(partner['Autonomy_self_reflection__c'])168 p.autonomy_summative_assessments=self.str2bool(partner['Autonomy_summative_assessments__c'])169 p.collaboration_peer_feedback=self.str2bool(partner['Collaboration_peer_feedback__c'])170 p.collaboration_peer_interaction=self.str2bool(partner['Collaboration_peer_interaction__c'])171 p.collaboration_teacher_learner_contact=self.str2bool(partner['Collaboration_teacher_learner_contact__c'])172 p.collaboration_tutor=self.str2bool(partner['Collaboration_tutor__c'])173 p.content_batch_uploads=self.str2bool(partner['Content_batch_uploads__c'])174 p.content_resource_sharing=self.str2bool(partner['Content_resource_sharing__c'])175 p.content_sharing_among_courses=self.str2bool(partner['Content_sharing_among_courses__c'])176 p.customization_assessement_repository=self.str2bool(partner['Customization_assessment_repository__c'])177 p.customization_content_repository = self.str2bool(partner['Customization_content_repository__c'])178 p.customization_create_learning_outcomes=self.str2bool(partner['Customization_create_learning_outcomes__c'])179 p.customization_reorder_content=self.str2bool(partner['Customization_reorder_content__c'])180 p.customization_reorder_learning_outcomes=self.str2bool(partner['Customization_reorder_learning_outcomes__c'])181 p.feedback_early_warning=self.str2bool(partner['Feedback_early_warning__c'])182 p.feedback_individual_and_groups=self.str2bool(partner['Feedback_individual_and_group__c'])183 p.feedback_knowledge_gaps=self.str2bool(partner['Feedback_knowledge_gaps__c'])184 p.feedback_learner_progress_tasks=self.str2bool(partner['Feedback_learner_progress_tasks__c'])185 p.feedback_multipart=self.str2bool(partner['Feedback_multipart__c'])186 p.feedback_understanding=self.str2bool(partner['Feedback_understanding__c'])187 p.grading_change_scores=self.str2bool(partner['Grading_change_scores__c'])188 p.grading_class_and_student_level=self.str2bool(partner['Grading_class_and_student_level__c'])189 p.grading_group_work=self.str2bool(partner['Grading_group_work__c'])190 p.grading_learning_portfolio=self.str2bool(partner['Grading_learning_portfolio__c'])191 p.grading_rubric_based=self.str2bool(partner['Grading_rubric_based__c'])192 p.grading_tolerances_sig_fig=self.str2bool(partner['Grading_tolerances_sig_fig__c'])193 p.interactivity_annotate=self.str2bool(partner['Interactivity_annotate__c'])194 p.interactivity_different_representations=self.str2bool(partner['Interactivity_different_representations__c'])195 p.interactivity_gaming=self.str2bool(partner['Interactivity_gaming__c'])196 p.interactivity_previous_knowledge=self.str2bool(partner['Interactivity_previous_knowledge__c'])197 p.interactivity_simulations=self.str2bool(partner['Interactivity_simulations__c'])198 p.interactivity_varying_means=self.str2bool(partner['Interactivity_varying_means__c'])199 p.LMS_analytics=self.str2bool(partner['LMS_analytics__c'])200 p.LMS_sends_grades=self.str2bool(partner['LMS_sends_grades__c'])201 p.LMS_SSO=self.str2bool(partner['LMS_SSO__c'])202 p.measure_alternate_assessment=self.str2bool(partner['Measure_alternate_assessment__c'])203 p.measure_assessments_in_most=self.str2bool(partner['Measure_assessments_in_most__c'])204 p.measure_mapping=self.str2bool(partner['Measure_mapping__c'])205 p.reporting_competency=self.str2bool(partner['Reporting_competency__c'])206 p.reporting_student_workload=self.str2bool(partner['Reporting_student_workload__c'])207 p.scaffolding_hints=self.str2bool(partner['Scaffolding_hints__c'])208 p.scaffolding_learner_explanations=self.str2bool(partner['Scaffolding_learner_explanations__c'])209 p.scaffolding_mental_practice=self.str2bool(partner['Scaffolding_mental_practice__c'])210 p.scaffolding_narrative=self.str2bool(partner['Scaffolding_narrative__c'])211 p.scaffolding_social_intervention=self.str2bool(partner['Scaffolding_social_intervention__c'])212 p.usability_design_orients_users=self.str2bool(partner['Usability_design_orients_users__c'])213 p.usability_glossary=self.str2bool(partner['Usability_glossary__c'])214 p.usability_partial_progress=self.str2bool(partner['Usability_partial_progress__c'])215 p.accessibility_language_UI=self.str2bool(partner['Accessibility_language_UI__c'])216 p.accessibility_language_content=self.str2bool(partner['Accessibility_language_content__c'])217 p.accessibility_VPAT=self.str2bool(partner['Accessibility_VPAT__c'])218 p.accessibility_WCAG=self.str2bool(partner['Accessibility_WCAG__c'])219 p.accessibility_universal_design=self.str2bool(partner['Accessibility_Universal_Design__c'])220 p.instructional_level_k12=self.str2bool(partner['Instructional_level_K12__c'])221 p.instructional_level_higher_ed = self.str2bool(partner['Instructional_level_higher_ed__c'])222 p.online_teaching_peer_discussion=self.str2bool(partner['Online_teaching_peer_discussion__c'])223 p.online_teaching_lecture_streaming=self.str2bool(partner['Online_teaching_lecture_streaming__c'])224 p.online_teaching_in_lecture=self.str2bool(partner['Online_teaching_in_lecture__c'])225 p.online_teaching_asynchronous=self.str2bool(partner['Online_teaching_asynchronous__c'])226 p.online_teaching_audio_video=self.str2bool(partner['Online_teaching_audio_video__c'])227 p.online_teaching_academic_integrity=self.str2bool(partner['Online_teaching_academic_integrity__c'])228 p.online_teaching_teaching_labs=self.str2bool(partner['Online_teaching_labs__c'])229 p.international=self.str2bool(partner['International__c'])230 p.partnership_level=partner['Partnership_Level__c']231 p.equity_rating = partner['Equity_Rating__c']232 p.save()233 if created:234 created_partners = created_partners + 1235 else:236 updated_partners = updated_partners + 1237 # remove partners that have been deleted from Salesforce238 stale_partners = Partner.objects.exclude(salesforce_id__in=partner_ids)239 stale_partners.delete()240 # set Partner Field Names to hidden = true, if they are not used by any partner241 partners = Partner.objects.all()242 partner_field_names = PartnerFieldNameMapping.objects.values_list('salesforce_name', flat=True)243 hidden_field_names = PartnerFieldNameMapping.objects.values_list('salesforce_name', flat=True).filter(hidden=True)...

Full Screen

Full Screen

test_str.py

Source:test_str.py Github

copy

Full Screen

...19"""20from unittest import TestCase21from sc4py.str import str2bool22class TestPythonBrfiedInit(TestCase):23 def test_str2bool(self):24 self.assertTrue(str2bool(True))25 self.assertTrue(str2bool('True'))26 self.assertTrue(str2bool('true'))27 self.assertTrue(str2bool('TRUE'))28 self.assertTrue(str2bool('verdade'))29 self.assertTrue(str2bool('Verdade'))30 self.assertTrue(str2bool('Yes'))31 self.assertTrue(str2bool('yes'))32 self.assertTrue(str2bool('YES'))33 self.assertTrue(str2bool('Sim'))34 self.assertTrue(str2bool('sim'))35 self.assertTrue(str2bool('SIM'))36 self.assertTrue(str2bool('T'))37 self.assertTrue(str2bool('t'))38 self.assertTrue(str2bool('v'))39 self.assertTrue(str2bool('V'))40 self.assertTrue(str2bool('Y'))41 self.assertTrue(str2bool('y'))42 self.assertTrue(str2bool('s'))43 self.assertTrue(str2bool('S'))44 self.assertTrue(str2bool('1'))45 self.assertTrue(str2bool(1))46 self.assertFalse(str2bool(False))47 self.assertFalse(str2bool('False'))48 self.assertFalse(str2bool('false'))49 self.assertFalse(str2bool('FALSE'))50 self.assertFalse(str2bool('Falso'))51 self.assertFalse(str2bool('falso'))52 self.assertFalse(str2bool('FALSO'))53 self.assertFalse(str2bool('No'))54 self.assertFalse(str2bool('no'))55 self.assertFalse(str2bool('NO'))56 self.assertFalse(str2bool('Nao'))57 self.assertFalse(str2bool('nao'))58 self.assertFalse(str2bool('NAO'))59 self.assertFalse(str2bool('Não'))60 self.assertFalse(str2bool('não'))61 self.assertFalse(str2bool('NÃO'))62 self.assertFalse(str2bool('F'))63 self.assertFalse(str2bool('f'))64 self.assertFalse(str2bool('N'))65 self.assertFalse(str2bool('n'))66 self.assertFalse(str2bool('0'))67 self.assertFalse(str2bool(0))68 self.assertIsNone(str2bool(None))69 self.assertIsNone(str2bool(''))70 self.assertIsNone(str2bool(' '))...

Full Screen

Full Screen

tests.py

Source:tests.py Github

copy

Full Screen

1import pytest2import entrypoint_helpers as eh3def test_str2bool():4 assert eh.str2bool('True')5 assert eh.str2bool('1')6 assert eh.str2bool(1)7 assert eh.str2bool('y')8 assert eh.str2bool('Y')9 assert eh.str2bool(None) == False10 assert not eh.str2bool(2)11 assert not eh.str2bool('false')12 assert not eh.str2bool('n')13 assert not eh.str2bool('something else')14def test_str2bool_or():15 assert eh.str2bool_or(None, False) == False16 assert eh.str2bool_or('True', False)17 assert eh.str2bool_or('1', False)18 assert eh.str2bool_or(1, False)19 assert eh.str2bool_or('y', False)20 assert eh.str2bool_or('Y', False)21 assert not eh.str2bool_or(2, True)22 assert not eh.str2bool_or('false', True)23 assert not eh.str2bool_or('n', True)...

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