def test_save_data_saves_model_to_file_as_json(consumestore_fixture):
    """Test consumestore.save_data saves the model to the passed file.

    Model should be saved as JSON.
    """
    test_consumestore = consumestore_fixture
    test_consumestore.save_data()

    assert os.path.exists(TEST_FILE)
    assert os.path.isfile(TEST_FILE)

    line = fileops.get_line_from_file(TEST_FILE).next()

    for key, value in EXPECTED_DATA_DICT.iteritems():
        assert value in line

    os.remove(TEST_FILE)
Exemple #2
0
def test_consumer_writes_data_to_file(client_fixture):
    """Test workers.consumer writes correct data to file system."""
    consumer(TEST_SITE, TEST_URI)

    assert os.path.isfile(EXPECTED_MEDIA_FILE)

    assert os.path.exists(EXPECTED_FILE)
    assert os.path.isfile(EXPECTED_FILE)

    line = fileops.get_line_from_file(EXPECTED_FILE).next()

    for key, value in EXPECTED_DATA_DICT.iteritems():
        assert value in line

    os.remove(EXPECTED_FILE)
    shutil.rmtree(os.path.join(
        fileops.IMG_DIR,
        TEST_CLASSIFICATION,
        TEST_SITE
    ))