def test_silo_detail_import_done(self): # Create Silo, Read and CeleryTask read_type = factories.ReadType(read_type="CSV") read = factories.Read(owner=self.user, type=read_type, read_name="TEST SILO DONE", description="unittest") silo = factories.Silo(owner=self.user, public=False) silo.reads.add(read) factories.CeleryTask(content_object=read, task_status=CeleryTask.TASK_FINISHED) factories.TolaUser(user=self.user) # Check view request = self.factory.get(self.silo_detail_url) request.user = self.user response = silo_detail(request, silo.pk) self.assertContains( response, '<a href="/show_read/{}" target="_blank">{}</a>'.format( read.id, read.read_name)) self.assertNotContains( response, '<span class="btn-sm btn-danger">Import Failed</span>') self.assertNotContains( response, '<span class="btn-sm btn-warning">Import running</span>') self.assertNotContains( response, '<h4 style="color:#ff3019">Import process failed</h4>') self.assertNotContains(response, '<h4>Import process running</h4>')
def test_new_silodata(self, mock_get_workflowteams): mock_get_workflowteams.return_value = [] read_type = ReadType.objects.get(read_type="CSV") upload_file = open('silo/tests/sample_data/test.csv', 'rb') read = factories.Read(owner=self.tola_user.user, type=read_type, read_name="TEST CSV IMPORT", description="unittest", file_data=SimpleUploadedFile( upload_file.name, upload_file.read())) params = { "read_id": read.pk, "new_silo": "Test CSV Import", } request = self.factory.post(self.upload_csv_url, data=params) request.user = self.tola_user.user request._dont_enforce_csrf_checks = True response = uploadFile(request, read.pk) self.assertEqual(response.status_code, 302) self.assertIn("/silo_detail/", response.url) silo = Silo.objects.get(name="Test CSV Import") request = self.factory.get(self.silo_detail_url) request.user = self.tola_user.user response = silo_detail(request, silo.pk) self.assertEqual(response.status_code, 200) # now delete that silo data cause this uses the custom database LabelValueStore.objects.filter(First_Name="Bob", Last_Name="Smith", silo_id="1", read_id="1").delete() LabelValueStore.objects.filter(First_Name="John", Last_Name="Doe", silo_id="1", read_id="1").delete() LabelValueStore.objects.filter(First_Name="Joe", Last_Name="Schmoe", silo_id="1", read_id="1").delete() LabelValueStore.objects.filter(First_Name="جان", Last_Name="ډو", silo_id="1", read_id="1").delete()