Exemple #1
0
def test_cwf_init():
    from cwf2neo import CWF

    cwf = CWF()

    cwf.setup_neo4j_connection()

    assert cwf.db.graph.database.name
Exemple #2
0
def test_download_sources():
    from cwf2neo import CWF

    cwf = CWF()

    NICE_sources = cwf.config['data_sources']['NICE'].get()

    cwf.download_data_sources()

    file_to_check = os.path.join(cwf.temp_dir,
                                 NICE_sources['cwf']['local_filename'])
    file_to_check2 = os.path.join(
        cwf.temp_dir, NICE_sources['competencies']['local_filename'])

    assert os.path.exists(file_to_check) == 1 and \
        os.path.exists(file_to_check2) == 1
Exemple #3
0
def test_config_parse():
    """Test yaml configuration
    """
    from cwf2neo import CWF
    cwf = CWF()

    assert cwf.config['data_sources']['NIST']['cf']['source_url'].get() == \
        "https://www.nist.gov/file/448306"
Exemple #4
0
def test_file_download():
    """Ensure the function used to download files produces files on disk
     as expected
    """
    cwf = CWF()

    temp_dir = tempfile.mkdtemp()
    cwf = cwf.config['data_sources']['NICE']['cwf'].get()

    file_download(cwf['source_url'], temp_dir, cwf['local_filename'])

    assert os.path.exists(os.path.join(temp_dir, cwf['local_filename'])) == 1

    shutil.rmtree(temp_dir)
Exemple #5
0
#!/usr/bin/env python

# import logging
from cwf2neo import CWF
import logging

# Set logging level for more verbose output
logging.basicConfig(level=logging.INFO)

# Get an instance of the CWF object used to interact with the Neo4j database
cwf = CWF(neo4j_host='neo4j',
          neo4j_user='******',
          neo4j_pass='******',
          neo4j_port=7687)

# Import the NIST/NICE data into Neo4j
cwf.initialize()
Exemple #6
0
#!/usr/bin/env python

if __name__ == "__main__":
    import logging

    from cwf2neo import CWF

    logging.basicConfig(format='%(asctime)s %(levelname)s\t%(message)s',
                        level=logging.INFO,
                        datefmt='%Y-%m-%d %H:%M:%S')

    # Get an instance of the CWF object used to interact with Neo4j database
    cwf = CWF()

    # Import the NIST/NICE data into Neo4j
    cwf.initialize()