def mutate_and_get_payload(cls, root, info, owner, labbook_name, app_name, client_mutation_id=None): username = get_logged_in_username() lb = InventoryManager().load_labbook(username, owner, labbook_name, author=get_logged_in_author()) bam = BundledAppManager(lb) with lb.lock(): bam.remove_bundled_app(app_name) return SetBundledApp( environment=Environment(name=labbook_name, owner=owner))
def test_remove_app(self, mock_labbook): """Test removing a bundled app""" bam = BundledAppManager(mock_labbook[2]) assert os.path.exists(bam.bundled_app_file) is False bam.add_bundled_app(8050, 'dash 1', 'a demo dash app 1', 'python app1.py') bam.add_bundled_app(9000, 'dash 2', 'a demo dash app 2', 'python app2.py') bam.add_bundled_app(9001, 'dash 3', 'a demo dash app 3', 'python app3.py') apps = bam.get_bundled_apps() assert os.path.exists(bam.bundled_app_file) is True assert 'dash 1' in apps assert apps['dash 1']['port'] == 8050 assert apps['dash 1']['description'] == 'a demo dash app 1' assert apps['dash 1']['command'] == 'python app1.py' assert 'dash 2' in apps assert apps['dash 2']['port'] == 9000 assert apps['dash 2']['description'] == 'a demo dash app 2' assert apps['dash 2']['command'] == 'python app2.py' assert 'dash 3' in apps assert apps['dash 3']['port'] == 9001 assert apps['dash 3']['description'] == 'a demo dash app 3' assert apps['dash 3']['command'] == 'python app3.py' bam.remove_bundled_app('dash 2') apps = bam.get_bundled_apps() assert 'dash 1' in apps assert 'dash 2' not in apps assert 'dash 3' in apps bam.remove_bundled_app('dash 3') apps = bam.get_bundled_apps() assert 'dash 1' in apps assert 'dash 2' not in apps assert 'dash 3' not in apps bam.remove_bundled_app('dash 1') apps = bam.get_bundled_apps() assert len(apps.keys()) == 0 assert isinstance(apps, OrderedDict)
def test_remove_app_errors(self, mock_labbook): """Test errors when removing""" bam = BundledAppManager(mock_labbook[2]) with pytest.raises(ValueError): bam.remove_bundled_app("fake")