def test_workstation_update_view(client): w = WorkstationFactory() user = UserFactory() w.add_editor(user=user) title = "my Workstation" description = "my AWESOME workstation" assert w.title != title assert w.description is None response = get_view_for_user( client=client, method=client.post, viewname="workstations:update", reverse_kwargs={"slug": w.slug}, user=user, data={ "title": title, "description": description }, ) w.refresh_from_db() assert response.status_code == 302 assert w.title == title assert w.description == description
def test_workstationimage_create(client): u2 = UserFactory() VerificationFactory(user=u2, is_verified=True) w1 = WorkstationFactory() w2 = WorkstationFactory() w2.add_editor(user=u2) user_upload = UserUploadFactory(filename="test_image.tar.gz", creator=u2) user_upload.status = user_upload.StatusChoices.COMPLETED user_upload.save() assert w1.workstationimage_set.count() == 0 assert w2.workstationimage_set.count() == 0 response = get_view_for_user( client=client, method=client.post, viewname="workstations:image-create", reverse_kwargs={"slug": w2.slug}, user=u2, data={ "user_upload": user_upload.pk, "creator": u2.pk, "workstation": w2.pk, "initial_path": "a", "websocket_port": 1337, "http_port": 1234, }, ) assert response.status_code == 302 w1.refresh_from_db() w2.refresh_from_db() assert w1.workstationimage_set.count() == 0 w2_images = w2.workstationimage_set.all() assert len(w2_images) == 1 assert w2_images[0].creator == u2 assert w2_images[0].websocket_port == 1337 assert w2_images[0].http_port == 1234 assert w2_images[0].user_upload == user_upload assert w2_images[0].initial_path == "a"
def test_workstationimage_create(client): u2 = UserFactory() w1 = WorkstationFactory() w2 = WorkstationFactory() w2.add_editor(user=u2) staged_file = StagedFileFactory(file__filename="example.tar.gz") assert w1.workstationimage_set.count() == 0 assert w2.workstationimage_set.count() == 0 response = get_view_for_user( client=client, method=client.post, viewname="workstations:image-create", reverse_kwargs={"slug": w2.slug}, user=u2, data={ "chunked_upload": staged_file.file_id, "initial_path": "a", "websocket_port": 1337, "http_port": 1234, }, ) assert response.status_code == 302 w1.refresh_from_db() w2.refresh_from_db() assert w1.workstationimage_set.count() == 0 w2_images = w2.workstationimage_set.all() assert len(w2_images) == 1 assert w2_images[0].creator == u2 assert w2_images[0].websocket_port == 1337 assert w2_images[0].http_port == 1234 assert w2_images[0].staged_image_uuid == staged_file.file_id assert w2_images[0].initial_path == "a"
def test_workstationimage_detail(client): user = UserFactory() ws = WorkstationFactory() wsi1, wsi2 = ( WorkstationImageFactory(workstation=ws), WorkstationImageFactory(workstation=ws), ) ws.add_editor(user=user) response = get_view_for_user( viewname="workstations:image-detail", reverse_kwargs={ "slug": ws.slug, "pk": wsi1.pk }, client=client, user=user, ) assert response.status_code == 200 assert str(wsi1.pk) in response.rendered_content assert str(wsi2.pk) not in response.rendered_content