Exemplo n.º 1
0
def test_empty_cells(client):
    #the bug is described in issue 153
    files_dir = os.path.join(os.path.dirname(__file__), "files_for_tests",
                             "empty_cells")

    #change project settings
    url = '/api/project/settings?project_folder={path}'.format(path=files_dir)
    response = client.put(url, json=dict(warnEmpty=False))

    #get project results
    data = get_yaml_calculation(client, files_dir, "fertilizer.xlsx", "Sheet1",
                                "t2wml.yaml")

    #change project settings
    url = '/api/project/settings?project_folder={path}'.format(path=files_dir)
    response = client.put(url, json=dict(warnEmpty=True))

    #reapply yaml:
    response = load_yaml_file(client, files_dir,
                              os.path.join(files_dir, "t2wml.yaml"),
                              "fertilizer.xlsx", "Sheet1")
    data2 = response.data.decode("utf-8")
    data2 = json.loads(data2)

    #once again, this is cheating
    error_cells_1 = data["layers"]["type"]["entries"][4]["indices"]
    error_cells_2 = data2["layers"]["type"]["entries"][4]["indices"]
    assert error_cells_1 != error_cells_2
Exemplo n.º 2
0
def test_empty_cells(client):
    #the bug is described in issue 153
    files_dir=os.path.join(os.path.dirname(__file__), "files_for_tests", "empty_cells")

    #load project
    url='/api/project/load?project_folder={path}'.format(path=files_dir)
    response=client.post(url)
    data = response.data.decode("utf-8")
    data = json.loads(data)

    #change project settings
    url='/api/project/settings?project_folder={path}'.format(path=files_dir)
    response=client.put(url,
            data=dict(
            warnEmpty=False
        )) 

    #get project results
    data= get_project_files(client, files_dir)

    #change project settings
    url='/api/project/settings?project_folder={path}'.format(path=files_dir)
    response=client.put(url,
            data=dict(
            warnEmpty=True
        )) 
    
    #reapply yaml:
    response=load_yaml_file(client, files_dir, filename=os.path.join(files_dir, "t2wml.yaml"))
    data2 = response.data.decode("utf-8")
    data2 = json.loads(data2)

    error_cells_1=data["yamlData"]["yamlRegions"]["dangerCells"]['list']
    error_cells_2=data2["yamlRegions"]["dangerCells"]["list"]
    assert set(error_cells_1)!=set(error_cells_2)
Exemplo n.º 3
0
 def test_998_reset_global_settings(self, client):
     #reset to old settings:
     url='/api/project/globalsettings'.format(project_folder=project_folder)
     response=client.put(url,
             json=dict(
             datamartIntegration=datamart_integration_switch
         ))
Exemplo n.º 4
0
 def test_01b_change_project_name(self, client):
     url = '/api/project?project_folder={project_folder}'.format(
         project_folder=project_folder)
     ptitle = "Unit test"
     response = client.put(url, data=dict(ptitle=ptitle))
     data = response.data.decode("utf-8")
     data = json.loads(data)
     assert data['project']['title'] == ptitle
Exemplo n.º 5
0
def test_datamart_integration(client):
    #create project:
    project_folder = create_project(client)

    #get old settings:
    url = '/api/project/globalsettings'
    response = client.get(url)
    data = response.data.decode("utf-8")
    data = json.loads(data)
    old_global_settings = data

    #set new settings
    url = '/api/project/globalsettings'
    endpoint = 'https://*****:*****@dsbox02.isi.edu:8888/datamart-api-wm'
    response = client.put(url,
                          json=dict(datamartApi=endpoint,
                                    datamartIntegration=True))

    #upload data file
    filename = os.path.join(os.path.dirname(__file__), "files_for_tests",
                            "region.xlsx")
    response = load_data_file(client, project_folder, filename)
    data = response.data.decode("utf-8")
    data = json.loads(data)

    #reset to old settings:
    url = '/api/project/globalsettings'
    endpoint = 'https://*****:*****@dsbox02.isi.edu:8888/datamart-api'  #'https://*****:*****@dsbox02.isi.edu:8888/datamart-api-wm'
    response = client.put(
        url,
        json=dict(
            datamartApi=old_global_settings["datamart_api"],
            datamartIntegration=old_global_settings["datamart_integration"]))

    #check validity
    #with open (os.path.join(os.path.dirname(__file__), "files_for_tests", "datamart_results.json"), 'w') as f:
    #     json.dump(data["layers"], f, sort_keys=False, indent=4)

    with open(
            os.path.join(os.path.dirname(__file__), "files_for_tests",
                         "datamart_results.json"), 'r') as f:
        expected_layers = json.load(f)

    assert data["layers"] == expected_layers
Exemplo n.º 6
0
    def test_01a_clear_annotation_settings(self, client):
        #get old settings:
        url='/api/project/globalsettings'
        response=client.get(url)
        data = response.data.decode("utf-8")
        data = get_data(data)
        global datamart_integration_switch
        datamart_integration_switch=data["datamart_integration"]

        #set new settings
        url='/api/project/globalsettings'
        response=client.put(url,
                json=dict(
                datamartIntegration=False
            ))
Exemplo n.º 7
0
    def test_14_settings(self, client):
        from t2wml.settings import t2wml_settings
        #PUT '/api/project/{project_folder}/settings'
        url = '/api/project/settings?project_folder={project_folder}'.format(
            project_folder=project_folder)
        endpoint = 'https://query.wikidata.org/bigdata/namespace/wdq/sparql'
        response = client.put(url,
                              data=dict(endpoint=endpoint, warnEmpty=False))
        assert t2wml_settings.wikidata_provider.sparql_endpoint == endpoint

        #GET '/api/project/{project_folder}/settings'
        url = '/api/project/settings?project_folder={project_folder}'.format(
            project_folder=project_folder)
        response = client.get(url)
        data = response.data.decode("utf-8")
        data = json.loads(data)
        assert data[
            "endpoint"] == 'https://query.wikidata.org/bigdata/namespace/wdq/sparql'
        assert data["warnEmpty"] == False