# -*- coding: utf-8 -*-
from flask import url_for
from scout.server.extensions import store


def test_managed_variants(app, user_obj, institute_obj):
    # GIVEN an initialized app
    # GIVEN a valid user and institute

    with app.test_client() as client:
        # GIVEN that the user could be logged in
        resp = client.get(url_for("auto_login"))
        assert resp.status_code == 200

        # WHEN accessing the cases page
        resp = client.get(url_for("managed_variants.managed_variants"))

        # THEN it should return a page
        assert resp.status_code == 200

@@ -424,12 +424,23 @@
 the 
-case
+managed variant
 s pa
@@ -550,24 +550,24 @@
 turn a page%0A
-
         asse
@@ -573,28 +573,2183 @@
 ert resp.status_code == 200%0A
+%0A%0Adef test_add_and_remove_managed_variants(app, user_obj, institute_obj):%0A    # GIVEN an initialized app%0A    # GIVEN a user and institute%0A%0A    with app.test_client() as client:%0A        # GIVEN that the user could be logged in%0A        resp = client.get(url_for(%22auto_login%22))%0A        assert resp.status_code == 200%0A%0A        # GIVEN data from a filled out form%0A        add_form_data = %7B%0A            %22chromosome%22: %2214%22,%0A            %22position%22: 76548781,%0A            %22category%22: %22snv%22,%0A            %22sub_category%22: %22indel%22,%0A            %22reference%22: %22CTGGACC%22,%0A            %22alternative%22: %22G%22,%0A        %7D%0A%0A        # WHEN attempting to add a valid variant%0A        resp = client.post(%0A            url_for(%22managed_variants.add_managed_variant%22),%0A            data=add_form_data,%0A        )%0A        # THEN status should be redirect%0A        assert resp.status_code == 302%0A        # THEN one variant should be present in the managed variant collection%0A        assert sum(1 for i in store.managed_variant_collection.find()) == 1%0A        # THEN the correct variant should be found inserted into the database%0A        test_managed_variant = store.managed_variant_collection.find_one()%0A        assert test_managed_variant%5B%22chromosome%22%5D == %2214%22%0A%0A        # THEN attempting a duplicate insertion will return an error%0A        resp = client.post(%0A            url_for(%22managed_variants.add_managed_variant%22),%0A            data=add_form_data,%0A        )%0A        # THEN the status code should still be redirect%0A        assert resp.status_code == 302%0A        # THEN the database should still contatain only one variant%0A        assert sum(1 for i in store.managed_variant_collection.find()) == 1%0A%0A        # WHEN requesting to remove the selected variant%0A        resp = client.post(%0A            url_for(%0A                %22managed_variants.remove_managed_variant%22,%0A                variant_id=test_managed_variant%5B%22managed_variant_id%22%5D,%0A            )%0A        )%0A        # THEN the status code should again be redirect%0A        assert resp.status_code == 302%0A        # THEN no variants should remain in the collection%0A        assert sum(1 for i in store.managed_variant_collection.find()) == 0%0A

Add more view tests