def setUp(self): super(WorkflowViewTests, self).setUp() # log in self.log_patcher = patch('server.utils.log_user_event') self.log_patch = self.log_patcher.start() self.factory = APIRequestFactory() self.workflow1 = add_new_workflow('Workflow 1') self.workflow2 = add_new_workflow('Workflow 2') self.module_version1 = add_new_module_version('Module 1') add_new_module_version('Module 2') add_new_module_version('Module 3') # Add another user, with one public and one private workflow self.otheruser = User.objects.create(username='******', email='*****@*****.**', password='******') self.other_workflow_private = Workflow.objects.create( name="Other workflow private", owner=self.otheruser ) self.other_workflow_public = Workflow.objects.create( name="Other workflow public", owner=self.otheruser, public=True )
def test_workflow_init_state(self): # checks to make sure the right initial data is embedded in the HTML (username etc.) with patch.dict( 'os.environ', { 'CJW_INTERCOM_APP_ID': 'myIntercomId', 'CJW_GOOGLE_ANALYTICS': 'myGaId' }): # create an Edit Cells module so we can check that its ID is returned correctly edit_cells_module_id = add_new_module_version( 'Edit Cells', id_name='editcells').module_id load_update_table_module_ids.cache_clear() response = self.client.get( '/workflows/%d/' % self.workflow1.id) # need trailing slash or 301 self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertContains(response, '"loggedInUser"') self.assertContains(response, user_display(self.user)) self.assertContains(response, self.user.email) self.assertContains(response, '"editcells": ' + str(edit_cells_module_id)) self.assertContains(response, '"workflow"') self.assertContains(response, '"modules"') self.assertNotContains(response, '"reorder-column"') self.assertContains(response, 'myIntercomId') self.assertContains(response, 'myGaId')
def createTestWorkflow(self): # Create a standard test workflow, but it has only one module so add two more to test render pipeline # Throw a missing value in there to test handling of NA values test_csv = 'Class,M,F\n' \ 'math,10,12\n' \ 'english,,7\n' \ 'history,11,13\n' \ 'economics,20,20' self.test_table = pd.read_csv(io.StringIO(test_csv), header=0, skipinitialspace=True) self.workflow1 = create_testdata_workflow(csv_text=test_csv) self.pspec11 = ParameterSpec.objects.get(id_name='csv') self.module2_version = add_new_module_version('Module 2', dispatch='NOP') self.pspec21 = add_new_parameter_spec(self.module2_version, ParameterSpec.STRING, def_value='foo') self.pspec22 = add_new_parameter_spec(self.module2_version, ParameterSpec.FLOAT, def_value=3.14) self.pspec23 = add_new_parameter_spec(self.module2_version, ParameterSpec.INTEGER, def_value=42) self.pspec24 = add_new_parameter_spec(self.module2_version, ParameterSpec.CHECKBOX, def_value=True) self.pspec25 = ParameterSpec.objects.create( module_version=self.module2_version, type=ParameterSpec.MENU, def_menu_items='Apple|Banana|Kittens', def_value='1') self.module3_version = add_new_module_version('Module 3', dispatch='double_M_col') self.pspec31 = add_new_parameter_spec(self.module3_version, ParameterSpec.BUTTON) self.wfmodule1 = WfModule.objects.get(order=0) self.wfmodule2 = add_new_wf_module(self.workflow1, self.module2_version, 1) self.wfmodule3 = add_new_wf_module(self.workflow1, self.module3_version, 2)
def setUp(self): super(ChannelTests, self).setUp() self.user = create_test_user(username='******', email='*****@*****.**') self.workflow = add_new_workflow('Workflow 1') self.wf_id = self.workflow.id self.module = add_new_module_version('Module') self.wf_module = add_new_wf_module(self.workflow, self.module) self.application = self.mock_auth_middleware(create_url_router())
def setUp(self): super().setUp() clear_db() self.user = create_test_user(username='******', email='*****@*****.**') self.workflow = Workflow.objects.create(name='Workflow 1', owner=self.user) self.wf_id = self.workflow.id self.module = add_new_module_version('Module') self.wf_module = add_new_wf_module(self.workflow, self.module) self.application = self.mock_auth_middleware(create_url_router()) self.communicators = []
def test_workflow_duplicate(self): # Create workflow with two WfModules wf1 = create_testdata_workflow() self.assertNotEqual(wf1.owner, self.otheruser) # should owned by user created by LoggedInTestCase module_version1 = add_new_module_version('Module 1') add_new_wf_module(wf1, module_version1, 1) # order=1 self.assertEqual(wf1.wf_modules.count(), 2) wf2 = wf1.duplicate(self.otheruser) self.assertNotEqual(wf1.id, wf2.id) self.assertEqual(wf2.owner, self.otheruser) self.assertEqual(wf2.name, "Copy of " + wf1.name) self.assertIsNone(wf2.last_delta) # no undo history self.assertFalse(wf2.public) self.assertEqual(wf1.wf_modules.count(), wf2.wf_modules.count())
def createTestWorkflow(self): # Create a WfModule with one parameter of each type self.module_version = add_new_module_version("TestModule") self.moduleID = self.module_version.module.id stringSpec = ParameterSpec.objects.create( name='StringParam', id_name='stringparam', module_version=self.module_version, type=ParameterSpec.STRING, def_value='foo', placeholder='placeholder') stringSpecEmpty = ParameterSpec.objects.create( name='StringParamEmpty', id_name='stringparamempty', module_version=self.module_version, type=ParameterSpec.STRING) integerSpec = ParameterSpec.objects.create( name='IntegerParam', id_name='integerparam', module_version=self.module_version, type=ParameterSpec.INTEGER, def_value='42') floatSpec = ParameterSpec.objects.create( name='FloatParam', id_name='floatparam', module_version=self.module_version, type=ParameterSpec.FLOAT, def_value='10.11') checkboxSpec = ParameterSpec.objects.create( name='CheckboxParam', id_name='checkboxparam', module_version=self.module_version, type=ParameterSpec.CHECKBOX, def_value='1') menuSpec = ParameterSpec.objects.create( name='MenuParam', id_name='menuparam', module_version=self.module_version, type=ParameterSpec.MENU, def_items='Item A|Item B|Item C', def_value='1') # should refer to Item B radioSpec = ParameterSpec.objects.create( name='RadioParam', id_name='radioparam', module_version=self.module_version, type=ParameterSpec.RADIO, def_items='Item A|Item B|Item C', def_value='0') # should refer to Item A self.workflow = add_new_workflow(name="Test Workflow") self.workflowID = self.workflow.id self.wfmodule = WfModule.objects.create( module_version=self.module_version, workflow=self.workflow, order=0) self.wfmoduleID = self.wfmodule.id # set non-default values for vals in order to reveal certain types of bugs stringVal = ParameterVal.objects.create(parameter_spec=stringSpec, wf_module=self.wfmodule, value='fooval') self.stringID = stringVal.id emptyStringVal = ParameterVal.objects.create( parameter_spec=stringSpecEmpty, wf_module=self.wfmodule) self.stringemptyID = emptyStringVal.id integerVal = ParameterVal.objects.create(parameter_spec=integerSpec, wf_module=self.wfmodule, value='10') self.integerID = integerVal.id floatVal = ParameterVal.objects.create(parameter_spec=floatSpec, wf_module=self.wfmodule, value='3.14159') self.floatID = floatVal.id checkboxVal = ParameterVal.objects.create(parameter_spec=checkboxSpec, wf_module=self.wfmodule, value='True') self.checkboxID = checkboxVal.id menuVal = ParameterVal.objects.create(parameter_spec=menuSpec, wf_module=self.wfmodule, value='2', items=menuSpec.def_items) self.menuID = menuVal.id radioVal = ParameterVal.objects.create(parameter_spec=radioSpec, wf_module=self.wfmodule, value='0', items=radioSpec.def_items) self.radioID = radioVal.id