<commit_before>from flask import Flask, json
from flask.ext.testing import TestCase as FlaskTestCase

from collections import deque

from secret_truth import create_app, FORM_FIELD


class BaseTest(FlaskTestCase):
    ENDPOINT = '/secret'
    SECRET = dict(secret='My Secret')

    queue = None

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def create_app(self):
        self.queue = MyQueue()
        app = create_app(self.queue)
        app.config['TESTING'] = True
        return app

    def assert201(self, response):
        self.assertStatus(response, 201)


class TestEndPoints(BaseTest):

    def test_post_queue_adds_item(self):
        self.client.post(self.ENDPOINT, data=self.SECRET)
        self.assertEqual(self.queue.get(), self.SECRET[FORM_FIELD])

    def test_get_queue_returns_added_item(self):
        self.queue.post(self.SECRET[FORM_FIELD])
        resp = self.client.get(self.ENDPOINT)
        self.assertEqual(
                json.loads(resp.data)[FORM_FIELD],
                self.SECRET[FORM_FIELD]
        )


class MyQueue(deque):

    def get(self):
        return self.popleft()

    def post(self, item):
        self.append(item)<commit_msg>Added greenlit test to ensure items are removed<commit_after>from flask import Flask, json
from flask.ext.testing import TestCase as FlaskTestCase

from collections import deque

from secret_truth import create_app, FORM_FIELD


class BaseTest(FlaskTestCase):
    ENDPOINT = '/secret'
    SECRET = dict(secret='My Secret')

    queue = None

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def create_app(self):
        self.queue = MyQueue()
        app = create_app(self.queue)
        app.config['TESTING'] = True
        return app

    def assert201(self, response):
        self.assertStatus(response, 201)


class TestEndPoints(BaseTest):

    def test_post_queue_adds_item(self):
        self.client.post(self.ENDPOINT, data=self.SECRET)
        self.assertEqual(self.queue.get(), self.SECRET[FORM_FIELD])

    def test_get_queue_returns_added_item(self):
        self.queue.post(self.SECRET[FORM_FIELD])
        resp = self.client.get(self.ENDPOINT)
        self.assertEqual(
                json.loads(resp.data)[FORM_FIELD],
                self.SECRET[FORM_FIELD]
        )

    def test_ensure_item_removed_after_get(self):
        self.queue.post(self.SECRET[FORM_FIELD])
        self.client.get(self.ENDPOINT)
        self.assertTrue(self.queue.empty())


class MyQueue(deque):

    def get(self):
        return self.popleft()

    def post(self, item):
        self.append(item)

    def empty(self):
        return len(self) == 0
{'fraction_non_alphanumeric': 0.10175177040626164, 'fraction_numerical': 0.004845322400298174, 'mean_word_length': 2.7486033519553073, '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': '993654', 'n_tokens_mistral': 874, 'n_tokens_neox': 829, 'n_words': 168}