<commit_before>import unittest
from project import Project

from basecamp import Basecamp

class TestBasecamp(Basecamp):
    pass

class ProjectTests(unittest.TestCase):
    def setUp(self):
        self.username = "apitest"
        self.password = "<PASSWORD>"
        self.url = "http://apitesting.basecamphq.com/"
        self.project_id = 2849305

        self.project = Project(self.url, self.project_id,
                               self.username, self.password, basecamp=TestBasecamp)
        
    def test_latest_message(self):
        self.assertEqual("This is the newest message",
                         self.project.messages[0].title)

    def test_latest_comment(self):
        self.assertEqual("This is the latest comment",
                         self.project.comments[0].body)

    def test_late_milestones(self):
        self.assertEqual(3, len(self.project.late_milestones))

    def test_upcoming_milestones(self):
        self.assertEqual(3, len(self.project.upcoming_milestones))
<commit_msg>Succesfully caching data to a local dictionary.<commit_after>import unittest
from project import Project

from basecamp import Basecamp
from elementtree import ElementTree as ET

class TestBasecamp(Basecamp):
    def __init__(self, baseURL, username, password, fixture_file=None):
        self.__test_responses = { 'GET': {}, 'POST': {} }
        super(TestBasecamp, self).__init__(baseURL, username, password)
    
    def _request(self, path, data=None):
        try:
            result = self.__test_request_local(path, data)
            print "Cache hit"
        except KeyError:
            result = super(TestBasecamp, self)._request(path, data)
            self.__cache_result(path, data, result)
        return result

    def __cache_result(self, path, data, result):
        if data:
            data = ET.tostring(data)
            print "Cache miss: POST %s\n\t%s\n" % (path, data)
            if not self.__test_responses['POST'].has_key(path):
                self.__test_responses['POST'][path] = {}
            self.__test_responses['POST'][path][data] = result
        else:
            print "Cache miss: GET %s\n" % (path, )           
            self.__test_responses['GET'][path] = result
        return result

    def __test_request_local(self, path, data):
        if data:
            data = ET.tostring(data)
            return self.__test_responses['POST'][path][data]
        return self.__test_responses['GET'][path]

class ProjectTests(unittest.TestCase):
    def setUp(self):
        self.username = "apitest"
        self.password = "<PASSWORD>"
        self.url = "http://apitesting.basecamphq.com/"
        self.project_id = 2849305

        self.project = Project(self.url, self.project_id,
                               self.username, self.password, basecamp=TestBasecamp)
        
    def test_latest_message(self):
        self.assertEqual("This is the newest message",
                         self.project.messages[0].title)

    def test_latest_comment(self):
        self.assertEqual("This is the latest comment",
                         self.project.comments[0].body)

    def test_late_milestones(self):
        self.assertEqual(3, len(self.project.late_milestones))

    def test_upcoming_milestones(self):
        self.assertEqual(3, len(self.project.upcoming_milestones))

{'fraction_non_alphanumeric': 0.10542078466606769, 'fraction_numerical': 0.006588799041629231, 'mean_word_length': 2.4755463059313216, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2025681', 'n_tokens_mistral': 975, 'n_tokens_neox': 942, 'n_words': 201}