<commit_before>from service.server import app
from collections import namedtuple
import unittest
import json

import mock
import requests
import responses

TitleRegisterData = namedtuple('TitleRegisterData',
  ['title_number', 'register_data', 'geometry_data']
)
DN1000_title = TitleRegisterData('DN1000', "data", "geometry")

class ViewTitleTestCase(unittest.TestCase):

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

    def test_get_invalid_title_path_404(self):
        response = self.app.get('/titles/invalid-ref')
        assert response.status_code == 404

    @mock.patch('service.server.get_title_register', return_value=DN1000_title)
    def test_get_valid_title_path(self, mock_data):
        response = self.app.get('/titles/DN1000')
        assert response.status_code == 200

    @mock.patch('service.server.get_title_register', return_value=DN1000_title)
    def test_get_correct_title_number(self, mock_data):
        response = self.app.get('/titles/DN1000')
        self.assertTrue(str('"title_number": "DN1000"') in str(response.data))

    @mock.patch('service.server.get_title_register', return_value=DN1000_title)
    def test_get_correct_register_data(self, mock_data):
        response = self.app.get('/titles/DN1000')
        self.assertTrue(str('"data": "data"') in str(response.data))
        self.assertTrue(str('"geometry_data": "geometry"') in str(response.data))<commit_msg>Mock database call in 404 test case<commit_after>from service.server import app
from collections import namedtuple
import unittest
import json

import mock
import requests
import responses

TitleRegisterData = namedtuple('TitleRegisterData',
  ['title_number', 'register_data', 'geometry_data']
)
DN1000_title = TitleRegisterData('DN1000', "data", "geometry")

class ViewTitleTestCase(unittest.TestCase):

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

    @mock.patch('service.server.get_title_register', return_value=None)
    def test_get_invalid_title_path_404(self, mock_data):
        response = self.app.get('/titles/invalid-ref')
        assert response.status_code == 404

    @mock.patch('service.server.get_title_register', return_value=DN1000_title)
    def test_get_valid_title_path(self, mock_data):
        response = self.app.get('/titles/DN1000')
        assert response.status_code == 200

    @mock.patch('service.server.get_title_register', return_value=DN1000_title)
    def test_get_correct_title_number(self, mock_data):
        response = self.app.get('/titles/DN1000')
        self.assertTrue(str('"title_number": "DN1000"') in str(response.data))

    @mock.patch('service.server.get_title_register', return_value=DN1000_title)
    def test_get_correct_register_data(self, mock_data):
        response = self.app.get('/titles/DN1000')
        self.assertTrue(str('"data": "data"') in str(response.data))
        self.assertTrue(str('"geometry_data": "geometry"') in str(response.data))
{'fraction_non_alphanumeric': 0.12342740564433866, 'fraction_numerical': 0.03162189731383883, 'mean_word_length': 4.80276134122288, 'pattern_counts': {'":': 6, '<': 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': '2530785', 'n_tokens_mistral': 973, 'n_tokens_neox': 895, 'n_words': 160}