<commit_before>#!/usr/bin/env python
import os
from app import app
from app import db
import unittest
import tempfile


class AppTestCase(unittest.TestCase):
    def setUp(self):
        self.db_fd, self.db_filename = tempfile.mkstemp() 
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////' + self.db_filename
        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False
        self.client = app.test_client()
        db.create_all()

    def tearDown(self):
        os.close(self.db_fd)
        os.unlink(self.db_filename)

    def add_peer(self):
        self.client.post('/peers/add/', data=dict(
            name='Test1',
            host='::'
            ))

    def test_empty_db(self):
        """Start with a blank database."""
        rv = self.client.get('/peers/')
        assert b'No entries here so far' in rv.data

    def test_add_peer(self):
        self.add_peer()
        rv = self.client.get('/peers/')
        assert b'Test1' in rv.data

    def test_edit_peer(self):
        self.add_peer()
        self.client.post('/peers/edit/1', data=dict(
            name='Test2',
            host='::'
            ))
        rv = self.client.get('/peers/')
        assert b'Test2' in rv.data
        assert b'Test1' not in rv.data

if __name__ == '__main__':
    unittest.main()
<commit_msg>add delete test<commit_after>#!/usr/bin/env python
import os
from app import app
from app import db
import unittest
import tempfile


class AppTestCase(unittest.TestCase):
    def setUp(self):
        self.db_fd, self.db_filename = tempfile.mkstemp() 
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////' + self.db_filename
        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False
        self.client = app.test_client()
        db.create_all()

    def tearDown(self):
        os.close(self.db_fd)
        os.unlink(self.db_filename)

    def add_peer(self):
        self.client.post('/peers/add/', data=dict(
            name='Test1',
            host='::'
            ))

    def test_empty_db(self):
        """Start with a blank database."""
        rv = self.client.get('/peers/')
        assert b'No entries here so far' in rv.data

    def test_add_peer(self):
        self.add_peer()
        rv = self.client.get('/peers/')
        assert b'Test1' in rv.data

    def test_edit_peer(self):
        self.add_peer()
        self.client.post('/peers/edit/1', data=dict(
            name='Test2',
            host='::'
            ))
        rv = self.client.get('/peers/')
        assert b'Test2' in rv.data
        assert b'Test1' not in rv.data

    def test_delete_peer(self):
        self.add_peer()
        self.client.get('/peers/delete/1')
        rv = self.client.get('/peers/')
        assert b'Test1' not in rv.data

if __name__ == '__main__':
    unittest.main()

{'fraction_non_alphanumeric': 0.13893774182201898, 'fraction_numerical': 0.004924375659514597, 'mean_word_length': 2.1218441273326016, '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': '4563829', 'n_tokens_mistral': 951, 'n_tokens_neox': 935, 'n_words': 195}