<commit_before>require 'spec_base.rb'

describe "CouchDBAdmin" do
  it "creates a new database when one doesn't already exist" do
    database_name = "test_ragios_couchdb_admin_#{Time.now.to_i}"
    database_admin = {
      username: ENV['COUCHDB_ADMIN_USERNAME'],
      password: ENV['<PASSWORD>'],
      database: database_name,
      address: 'http://localhost',
      port: '5984'
    }

    Ragios::CouchdbAdmin.config(database_admin)
    Ragios::CouchdbAdmin.setup_database.should == true
    Ragios::CouchdbAdmin.get_database.class.should == Leanback::Couchdb
    #setup_database is idempotent
    Ragios::CouchdbAdmin.setup_database.should == true
    #teardown
    Ragios::CouchdbAdmin.get_database.delete
  end
end
<commit_msg>test ragios database security object creation<commit_after>require 'spec_base.rb'

describe "CouchDBAdmin" do
  it "creates a new database when one doesn't already exist" do
    database_name = "test_ragios_couchdb_admin_#{Time.now.to_i}"
    database_admin = {
      username: ENV['COUCHDB_ADMIN_USERNAME'],
      password: ENV['<PASSWORD>'],
      database: database_name,
      address: 'http://localhost',
      port: '5984'
    }

    Ragios::CouchdbAdmin.config(database_admin)
    Ragios::CouchdbAdmin.setup_database.should == true
    database = Ragios::CouchdbAdmin.get_database
    database.class.should == Leanback::Couchdb
    #setup_database is idempotent
    Ragios::CouchdbAdmin.setup_database.should == true
    username = database_admin[:username]
    if username
      database.security_object.should == {
                                            admins: {names: [username], roles: ["admin"]},
                                            readers: {names: [username],roles: ["admin"]}
                                          }
    else
      database.security_object.should == {}
    end
    #teardown
    Ragios::CouchdbAdmin.get_database.delete
  end
end

{'fraction_non_alphanumeric': 0.10542797494780794, 'fraction_numerical': 0.0041753653444676405, 'mean_word_length': 2.99375, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2540955', 'n_tokens_mistral': 604, 'n_tokens_neox': 592, 'n_words': 110}