| 38 | clear_test_media_root() |
| 39 | |
| 40 | def test_exports(self): |
| 41 | client = APIClient() |
| 42 | |
| 43 | with start_processing_node(): |
| 44 | user = User.objects.get(username="testuser") |
| 45 | self.assertFalse(user.is_superuser) |
| 46 | |
| 47 | other_user = User.objects.get(username="testuser2") |
| 48 | |
| 49 | project = Project.objects.create( |
| 50 | owner=user, |
| 51 | name="test project" |
| 52 | ) |
| 53 | other_project = Project.objects.create( |
| 54 | owner=other_user, |
| 55 | name="another test project" |
| 56 | ) |
| 57 | |
| 58 | # Start processing node |
| 59 | |
| 60 | # Create processing node |
| 61 | pnode = ProcessingNode.objects.create(hostname="localhost", port=11223) |
| 62 | assign_perm('view_processingnode', user, pnode) |
| 63 | assign_perm('view_processingnode', other_user, pnode) |
| 64 | |
| 65 | other_pnode = ProcessingNode.objects.create(hostname="localhost", port=11224) |
| 66 | assign_perm('view_processingnode', other_user, other_pnode) |
| 67 | |
| 68 | # task creation via file upload |
| 69 | image1 = open("app/fixtures/tiny_drone_image.jpg", 'rb') |
| 70 | image2 = open("app/fixtures/tiny_drone_image_2.jpg", 'rb') |
| 71 | |
| 72 | client.login(username="testuser", password="test1234") |
| 73 | |
| 74 | # Attempt to create a task with a processing node we have no access to |
| 75 | res = client.post("/api/projects/{}/tasks/".format(project.id), { |
| 76 | 'images': [image1, image2], |
| 77 | 'name': 'test task', |
| 78 | 'processing_node': other_pnode.id |
| 79 | }, format="multipart") |
| 80 | self.assertTrue(res.status_code == status.HTTP_400_BAD_REQUEST) |
| 81 | image1.seek(0) |
| 82 | image2.seek(0) |
| 83 | |
| 84 | # Normal case with images[], name and processing node parameter |
| 85 | res = client.post("/api/projects/{}/tasks/".format(project.id), { |
| 86 | 'images': [image1, image2], |
| 87 | 'name': 'test task', |
| 88 | 'processing_node': pnode.id |
| 89 | }, format="multipart") |
| 90 | self.assertTrue(res.status_code == status.HTTP_201_CREATED) |
| 91 | image1.close() |
| 92 | image2.close() |
| 93 | |
| 94 | # Should have returned the id of the newly created task |
| 95 | task = Task.objects.latest('created_at') |
| 96 | test_proj = "+proj=tmerc +lat_0=39.75527777777778 +lon_0=-104.8980555555556 +k=1.00025403 +x_0=182880.3657607315 +y_0=121920.2438404877 +ellps=GRS80 +units=us-ft +no_defs326" |
| 97 | |