def test_initialize_experiment(mock_reddit):
    r = mock_reddit.return_value
    patch('praw.')

    experiment_name = "stylesheet_experiment_test"

    with open(os.path.join(BASE_DIR,"config", "experiments", experiment_name + ".yml"), "r") as f:
        experiment_config = yaml.full_load(f)['test']

    assert len(db_session.query(Experiment).all()) == 0
    controller = StylesheetExperimentController(experiment_name, db_session, r, log)
    assert len(db_session.query(Experiment).all()) == 1
    experiment = controller.experiment
    assert experiment.name == experiment_name

    assert(experiment.controller == experiment_config['controller'])

    settings = json.loads(experiment.settings_json)
    for k in ['username', 'subreddit', 'subreddit_id', 'start_time', 'end_time', 'controller']:
        assert settings[k] == experiment_config[k]

    for condition_name in experiment_config['conditions']:
        with open(os.path.join(BASE_DIR,"config", "experiments", experiment_config['conditions'][condition_name]['randomizations']), "r") as f:
            conditions = []
            for row in csv.DictReader(f):
                conditions.append(row)

        with open(os.path.join(BASE_DIR,"config", "experiments", experiment_config['conditions'][condition_name]['randomizations']), "r") as f:
            nonconditions = []
            for row in csv.DictReader(f):
                nonconditions.append(row)

        assert len(settings['conditions'][condition_name]['randomizations']) == len(conditions)
        assert settings['conditions'][condition_name]['next_randomization']  == 0