def test_skills_searching(): """ Testing the search by skills. """ profile = Profile() # First clean any data from the DB. if profile.tableExists(): profile.deleteTable() profile.createTable() # Create dummy entries. profile.insert(json.load(open('dummy_json/roy.json'))) profile.insert(json.load(open('dummy_json/david.json'))) profile.insert(json.load(open('dummy_json/nir.json'))) # Start to run tests against the API. First, get the application. client = TestClient(app) # Search by skills. json_response = client.post('/search-by-skills', json={'skill': 'Drupal'}) assert json_response.json()[0]['match'] == 11 # Search for JavaScript. json_response = client.post('/search-by-skills', json={'skill': 'JavaScript'}) matches = {'nirgn': 18, 'roy-segall-304b054a': 16, 'davidbronfen': 12} for profile in json_response.json(): assert profile["match"] == matches[profile['user_id']]
import rethinkdb as r from models.Profile import Profile from tools.SettingsManager import SettingsManager settings = SettingsManager().loadSettings() print("----------") print("Installing DB") r.db_create(settings['db']['name']).run( r.connect(settings['db']['host'], settings['db']['port'])) print("The DB " + settings['db']['name'] + " now exists.") print("----------") print("\n") print("----------") print("Installing Profile") profile = Profile() profile.createTable() print("The table now exists") print("----------")