<commit_before>import os
import app
import unittest
import tempfile
import mock

class HomeTestCase(unittest.TestCase):

    def setUp(self):
        self.db_fd, app.app.config['DATABASE'] = tempfile.mkstemp()
        app.app.config['TESTING'] = True
        self.app = app.app.test_client()
        #app.init_db()

    def tearDown(self):
        os.close(self.db_fd)
        os.unlink(app.app.config['DATABASE'])

    @mock.patch('requests.get')
    def test_property(self, get_mock):
        class MockResponse(object):
            status_code = 200
            def json(self):
                return {
                "title": {
                    "title_number": "AB1234",
                    "address": "123 Fake St",
                    "registered_owners": [
                        {
                            "name": "Victor"
                        }
                    ],
                    "extent": {
                        "geometry": {
                            "type": "MultiPolygon",
                            "coordinates": [
                                [
                                    [
                                        [
                                            14708.755563011973,
                                            6761018.225448865
                                        ]
                                    ]
                                ]
                            ]
                        }
                    }
                }
            }
        get_mock.return_value = MockResponse()
        rv = self.app.get('/properties/EX1354')
        assert 'Your property' in rv.data
        assert '123 Fake St' in rv.data

if __name__ == '__main__':
    unittest.main()<commit_msg>add postcode search test case<commit_after>import os
import app
import unittest
import tempfile
import mock

class HomeTestCase(unittest.TestCase):

    def setUp(self):
        self.db_fd, app.app.config['DATABASE'] = tempfile.mkstemp()
        app.app.config['TESTING'] = True
        self.app = app.app.test_client()
        #app.init_db()

    def tearDown(self):
        os.close(self.db_fd)
        os.unlink(app.app.config['DATABASE'])

    @mock.patch('requests.get')
    def test_property(self, get_mock):
        class MockResponse(object):
            status_code = 200
            def json(self):
                return {
                "title": {
                    "title_number": "AB1234",
                    "address": "123 Fake St",
                    "registered_owners": [
                        {
                            "name": "Victor"
                        }
                    ],
                    "extent": {
                        "geometry": {
                            "type": "MultiPolygon",
                            "coordinates": [
                                [
                                    [
                                        [
                                            14708.755563011973,
                                            6761018.225448865
                                        ]
                                    ]
                                ]
                            ]
                        }
                    }
                }
            }
        get_mock.return_value = MockResponse()
        rv = self.app.get('/properties/EX1354')
        assert 'Your property' in rv.data
        assert '123 Fake St' in rv.data

    @mock.patch('requests.get')
    def test_postcode_filter(self, get_mock):
        class MockResponse(object):
            status_code = 200
            def json(self):
                return 
                {
                    "titles": [
                        {
                            "title_id": "AB1234",
                            "address": "123 Fake St",
                            "registered_owners": [
                                {
                                    "name": "Victor"
                                }
                            ],
                            "extent": {
                                "geometry": {
                                    "type": "MultiPolygon",
                                    "coordinates": [
                                        [
                                            [
                                                [
                                                    14708.755563011973,
                                                    6761018.225448865
                                                ]
                                            ]
                                        ]
                                    ]
                                }
                            }
                        },
                        {
                            "title_id": "AB1235",
                            "address": "124 Fake St",
                            "registered_owners": [
                                {
                                    "name": "Kiam"
                                }
                            ],
                            "extent": {
                                "geometry": {
                                    "type": "MultiPolygon",
                                    "coordinates": [
                                        [
                                            [
                                                [
                                                    14709.755563011973,
                                                    6761010.225448865
                                                ]
                                            ]
                                        ]
                                    ]
                                }
                            }
                        }
                    ]
                }                    
        get_mock.return_value = MockResponse()
        rv = self.app.get('/properties?postcode=AB12 3CD')
        assert '123 Fake St' in rv.data
        assert '124 Fake St' in rv.data

if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.07839326206673146, 'fraction_numerical': 0.031098153547133137, 'mean_word_length': 0.5724471606824548, 'pattern_counts': {'":': 35, '<': 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': 53, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2298483', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1223, 'n_words': 210}