How to use import_volume method in localstack

Best Python code snippet using localstack_python

test_import_volume_files.py

Source:test_import_volume_files.py Github

copy

Full Screen

1import pytest2import pytz3from graphql_relay import to_global_id4from unittest.mock import MagicMock5from datetime import datetime6from creator.projects.cavatica import (7 sync_cavatica_projects,8 sync_cavatica_account,9)10from creator.studies.models import Study11from creator.projects.models import Project12from creator.projects.factories import ProjectFactory13from creator.events.models import Event14from tests.projects.fixtures import CavaticaProject15IMPORT_FILES_MUTATION = """16mutation ImportVolumeFiles($project: ID!) {17 importVolumeFiles(project: $project) {18 project {19 projectId20 }21 }22}23"""24@pytest.mark.parametrize(25 "user_group,allowed",26 [27 ("Administrators", True),28 ("Services", False),29 ("Developers", False),30 ("Investigators", False),31 ("Bioinformatics", True),32 (None, False),33 ],34)35def test_import_files(db, mocker, clients, user_group, allowed):36 """37 Test that the correct users may import files38 """39 client = clients.get(user_group)40 project = ProjectFactory()41 import_volume = mocker.patch("creator.tasks.import_volume_files")42 resp = client.post(43 "/graphql",44 data={45 "query": IMPORT_FILES_MUTATION,46 "variables": {47 "project": to_global_id("ProjectNode", project.project_id)48 },49 },50 content_type="application/json",51 )52 if allowed:53 assert import_volume.call_count == 154 assert (55 resp.json()["data"]["importVolumeFiles"]["project"]["projectId"]56 == project.project_id57 )58 else:59 assert import_volume.call_count == 060 assert resp.json()["errors"][0]["message"] == "Not allowed"61def test_import_files_events(db, clients, mocker):62 """63 Test that the correct events are emitted64 """65 client = clients.get("Administrators")66 project = ProjectFactory()67 import_volume = mocker.patch("creator.tasks.import_volume_files")68 assert Event.objects.count() == 069 resp = client.post(70 "/graphql",71 data={72 "query": IMPORT_FILES_MUTATION,73 "variables": {74 "project": to_global_id("ProjectNode", project.project_id)75 },76 },77 content_type="application/json",78 )79 assert Event.objects.count() == 280 assert Event.objects.filter(event_type="IM_STR").count() == 181 assert Event.objects.filter(event_type="IM_SUC").count() == 182def test_import_files_no_project(db, clients, mocker):83 """84 Test that error is raised if project does not exist and the import task85 is never scheduled86 """87 client = clients.get("Administrators")88 import_volume = mocker.patch("creator.tasks.import_volume_files")89 resp = client.post(90 "/graphql",91 data={92 "query": IMPORT_FILES_MUTATION,93 "variables": {"project": to_global_id("ProjectNode", "ABC")},94 },95 content_type="application/json",96 )97 assert Event.objects.count() == 0...

Full Screen

Full Screen

vm_import.py

Source:vm_import.py Github

copy

Full Screen

...10 "VMImport.describe_conversion_tasks is not yet implemented"11 )12 def import_instance(self):13 raise NotImplementedError("VMImport.import_instance is not yet implemented")14 def import_volume(self):...

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