Ejemplo n.º 1
0
def test_convert_codelist_to_new_style(old_style_codelist, old_style_version):
    with assert_difference(old_style_codelist.versions.count,
                           expected_difference=1):
        actions.convert_codelist_to_new_style(codelist=old_style_codelist)

    converted_version = old_style_codelist.versions.order_by("id").last()
    assert converted_version.csv_data is None
    assert old_style_version.codes == converted_version.codes
Ejemplo n.º 2
0
def test_versions_post_ecl(client, user, user_codelist):
    data = {"ecl": "<<128133004 OR 156659008"}

    with assert_difference(user_codelist.versions.count,
                           expected_difference=1):
        rsp = post(client, user_codelist.get_versions_api_url(), data, user)

    assert rsp.status_code == 200
Ejemplo n.º 3
0
def test_versions_post_codes(client, user, user_codelist):
    data = {"codes": ["128133004", "156659008"]}

    with assert_difference(user_codelist.versions.count,
                           expected_difference=1):
        rsp = post(client, user_codelist.get_versions_api_url(), data, user)

    assert rsp.status_code == 200
Ejemplo n.º 4
0
def test_export_to_builder(organisation_user, new_style_version):
    with assert_difference(new_style_version.codelist.versions.count,
                           expected_difference=1):
        draft = actions.export_to_builder(version=new_style_version,
                                          owner=organisation_user)

    assert draft.draft_owner == organisation_user
    assert draft.codes == new_style_version.codes
    assert draft.code_objs.count() == new_style_version.code_objs.count()
    assert draft.searches.count() == new_style_version.searches.count()
Ejemplo n.º 5
0
def test_codelists_post(client, user):
    data = {
        "name": "New codelist",
        "coding_system_id": "snomedct",
        "codes": ["128133004", "156659008"],
    }

    with assert_difference(user.codelists.count, expected_difference=1):
        rsp = post(client, user.get_codelists_api_url(), data, user)

    assert rsp.status_code == 200
def test_post_success(client, old_style_codelist):
    force_login(old_style_codelist, client)

    csv_data = "code,description\n1068181000000106, Injury whilst synchronised swimming (disorder)"
    data = {
        "csv_data": csv_builder(csv_data),
    }

    with assert_difference(old_style_codelist.versions.count,
                           expected_difference=1):
        response = client.post(old_style_codelist.get_version_upload_url(),
                               data=data)

    clv = old_style_codelist.versions.filter(is_draft=True).last()
    assert response.status_code == 302
    assert response.url == clv.get_absolute_url()
Ejemplo n.º 7
0
def test_post_success(client, organisation, user):
    force_login(organisation, client)

    csv_data = "code,description\n1067731000000107,Injury whilst swimming (disorder)"
    data = {
        "name": "Test Codelist",
        "coding_system_id": "snomedct",
        "description": "This is a test",
        "methodology": "This is how we did it",
        "csv_data": csv_builder(csv_data),
        "reference-TOTAL_FORMS": "1",
        "reference-INITIAL_FORMS": "0",
        "reference-MIN_NUM_FORMS": "0",
        "reference-MAX_NUM_FORMS": "1000",
        "reference-0-text": "foo",
        "reference-0-url": "http://example.com",
        "signoff-TOTAL_FORMS": "1",
        "signoff-INITIAL_FORMS": "0",
        "signoff-MIN_NUM_FORMS": "0",
        "signoff-MAX_NUM_FORMS": "1000",
        "signoff-0-user": user.username,
        "signoff-0-date": "2020-01-23",
    }

    with assert_difference(organisation.codelists.count, expected_difference=1):
        response = client.post(organisation.get_codelist_create_url(), data=data)

    assert response.status_code == 302
    assert response.url == f"/codelist/{organisation.slug}/test-codelist/"

    codelist = organisation.codelists.last()
    assert codelist.name == "Test Codelist"

    # we should have one reference to example.com
    assert codelist.references.count() == 1
    ref = codelist.references.first()
    assert ref.url == "http://example.com"

    # we should have one signoff
    assert codelist.signoffs.count() == 1
    signoff = codelist.signoffs.first()
    assert signoff.user == user