<commit_before><commit_msg>Adding test framework.. cause ron is a little bitch<commit_after>#!/usr/bin/env python
import json
import os
import random
import roush
import string
import unittest
import tempfile

import database

class RoushTestCase(unittest.TestCase):

    def setUp(self):
        self.app = roush.app.test_client()

    def tearDown(self):
        pass

    def _generateRandomString(self,size):
        return "".join(random.choice(string.ascii_lowercase) for x in range(size))

    def test_empty_nodes(self):
        resp = self.app.get('/nodes')
        v = json.loads(resp.data)
        self.assertEqual(v['nodes'], [])

    def test_empty_clusters(self):
        resp = self.app.get('/clusters')
        v = json.loads(resp.data)
        self.assertEqual(v['clusters'], [])

    def test_empty_roles(self):
        resp = self.app.get('/roles')
        v = json.loads(resp.data)
        self.assertEqual(v['roles'], [])

    def test_create_role(self):
        name = self._generateRandomString(10)
        print name
        role_data = {"name": name, "description": "some text"}
        print json.dumps(role_data)
        resp = self.app.post('/roles', json.dumps(role_data))
        print resp

if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.12933753943217666, 'fraction_numerical': 0.0015772870662460567, 'mean_word_length': 2.9166666666666665, 'pattern_counts': {'":': 2, '<': 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': '2663429', 'n_tokens_mistral': 408, 'n_tokens_neox': 399, 'n_words': 87}