<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Integration tests for testing the application
HTTP routes and methods.

'''
import json
import flask
import unittest
import app.server as Server


class TestRoutes:
  '''
  Tests for all routes and methods.

  '''
  def __init__(self):
    self.app = Server.createServer('test', debug=False)
    self.client = self.app.test_client()

  def test_status_type(self):
    '''
    routes.status:  test the /status endpoint returns a JSON object.

    '''
    response = self.client.get('/status')
    result = json.loads(response.data.decode('utf8'))
    assert type(result) == type({})

  def test_status_object(self):
    '''
    routes.status:  test the /status endpoint returns a complete object.

    '''
    response = self.client.get('/status')
    result = json.loads(response.data.decode('utf8'))

    keys = ['online', 'version', 'description', 'repository', 'maintainer']
    for key in result.keys():
      assert key in keys<commit_msg>adding generic tests to new routes<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Integration tests for testing the application
HTTP routes and methods.

'''
import json
import flask
import unittest
import app.server as Server


class TestRoutes:
  '''
  Tests for all routes and methods.

  '''
  def __init__(self):
    self.app = Server.createServer('test', debug=False)
    self.client = self.app.test_client()

  #
  # /status
  #
  def test_status_type(self):
    '''
    routes:  /status endpoint returns a JSON object.

    '''
    response = self.client.get('/status')
    result = json.loads(response.data.decode('utf8'))
    assert type(result) == type({})

  def test_status_object(self):
    '''
    routes:  /status endpoint returns a complete object.

    '''
    response = self.client.get('/status')
    result = json.loads(response.data.decode('utf8'))

    keys = ['online', 'version', 'description', 'repository', 'maintainer']
    for key in result.keys():
      assert key in keys

  #
  # /users
  #
  def test_users_type(self):
    '''
    routes:  /users endpoint returns a JSON object.

    '''
    response = self.client.get('/users')
    result = json.loads(response.data.decode('utf8'))
    assert type(result) == type({})

  def test_users_object(self):
    '''
    routes:  /users endpoint returns a complete object.

    '''
    response = self.client.get('/users')
    result = json.loads(response.data.decode('utf8'))

    keys = ['success', 'message', 'endpoint', 'time', 'ETA', 'computations']
    for key in result.keys():
      assert key in keys

  #
  # /revisions
  #
  def test_revisions_type(self):
    '''
    routes:  /revisions endpoint returns a JSON object.

    '''
    response = self.client.get('/revisions')
    result = json.loads(response.data.decode('utf8'))
    assert type(result) == type({})

  def test_revisions_object(self):
    '''
    routes:  /revisions endpoint returns a complete object.

    '''
    response = self.client.get('/revisions')
    result = json.loads(response.data.decode('utf8'))

    keys = ['success', 'message', 'endpoint', 'time', 'ETA', 'computations']
    for key in result.keys():
      assert key in keys

  #
  # /datasets
  #
  def test_datasets_type(self):
    '''
    routes:  /datasets endpoint returns a JSON object.

    '''
    response = self.client.get('/datasets')
    result = json.loads(response.data.decode('utf8'))
    assert type(result) == type({})

  def test_datasets_object(self):
    '''
    routes:  /datasets endpoint returns a complete object.

    '''
    response = self.client.get('/datasets')
    result = json.loads(response.data.decode('utf8'))

    keys = ['success', 'message', 'endpoint', 'time', 'ETA', 'computations']
    for key in result.keys():
      assert key in keys

  #
  # /resources
  #
  def test_resources_type(self):
    '''
    routes:  /resources endpoint returns a JSON object.

    '''
    response = self.client.get('/resources')
    result = json.loads(response.data.decode('utf8'))
    assert type(result) == type({})

  def test_resources_object(self):
    '''
    routes:  /resources endpoint returns a complete object.

    '''
    response = self.client.get('/resources')
    result = json.loads(response.data.decode('utf8'))

    keys = ['success', 'message', 'endpoint', 'time', 'ETA', 'computations']
    for key in result.keys():
      assert key in keys

  #
  # /countries
  #
  def test_countries_type(self):
    '''
    routes:  /countries endpoint returns a JSON object.

    '''
    response = self.client.get('/countries')
    result = json.loads(response.data.decode('utf8'))
    assert type(result) == type({})

  def test_countries_object(self):
    '''
    routes:  /countries endpoint returns a complete object.

    '''
    response = self.client.get('/countries')
    result = json.loads(response.data.decode('utf8'))

    keys = ['success', 'message', 'endpoint', 'time', 'ETA', 'computations']
    for key in result.keys():
      assert key in keys

  #
  # /gallery_items
  #
  def test_gallery_items_type(self):
    '''
    routes:  /gallery_items endpoint returns a JSON object.

    '''
    response = self.client.get('/gallery_items')
    result = json.loads(response.data.decode('utf8'))
    assert type(result) == type({})

  def test_gallery_items_object(self):
    '''
    routes:  /gallery_items endpoint returns a complete object.

    '''
    response = self.client.get('/gallery_items')
    result = json.loads(response.data.decode('utf8'))

    keys = ['success', 'message', 'endpoint', 'time', 'ETA', 'computations']
    for key in result.keys():
      assert key in keys

  #
  # /organizations
  #
  def test_organizations_type(self):
    '''
    routes:  /organizations endpoint returns a JSON object.

    '''
    response = self.client.get('/organizations')
    result = json.loads(response.data.decode('utf8'))
    assert type(result) == type({})

  def test_organizations_object(self):
    '''
    routes:  /organizations endpoint returns a complete object.

    '''
    response = self.client.get('/organizations')
    result = json.loads(response.data.decode('utf8'))

    keys = ['success', 'message', 'endpoint', 'time', 'ETA', 'computations']
    for key in result.keys():
      assert key in keys

{'fraction_non_alphanumeric': 0.1517984471557598, 'fraction_numerical': 0.00316906987799081, 'mean_word_length': 3.144451739986868, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5681285', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1926, 'n_words': 486}