2011-03-13
Love/hate t-mobile
Tara and I recently got Nexus S phones from t-mobile. The phones are very cool but the voice quality is terrible. I just got off a call to their customer support and I could barely hear the guy. I recognized the Indian accent so I'm pretty sure my call was getting routed to ho-jai-gah land, but still. When you call the phone company's technical support line and you can't hear the guy on the other end, it does not inspire confidence. So, is this a t-mobile fail or is it a problem with the phone?
2011-03-12
Google Voice for the win.
I have a new Nexus S phone. I think it's super cool, and not in the least because it integrates with google voice. In fact, I understand it integrates pretty much perfectly. So... I'm making the switch. I tried porting my number with out success. I also note that Google Voice doesn't have any numbers available in the Santa Barbara area; I suspect the one has something to do with the other. I picked a Ventura number: 805-669-8839.
Following lifehacker's advice on switching to google voice, I configured my voice number to only ring through for people I know. Unrecognized numbers go directly to voicemail. But the whole point of GV is that the voicemail is actually useful. The iPhone's "visual voicemail" was a big step in the right direction, but GV's voicemail transcription... awesome. For anyone wondering, this is why I don't mind putting my phone number up there on the web: I'm not exposing myself to having my time or my phone minutes wasted.
Unfortunately t-mobile is refusing to allow me to redirect my mobile number's voicemail to GV voicemail. Apparently they won't let anyone on the flexpay contract do it. And they won't switch my contract to post-paid (or whatever it's called) for another 6 months. I even called the tech-support guys and asked them to override it, but no-can-do apparently. I guess they don't like the idea of people using GV, although this certainly doesn't stop it. I have to admit that I'm a little disgusted that t-mobile would sell me a Google branded phone and then try to block me from using a google service with it. I've set my t-mobile voicemail greeting to "I never check this voicemail box. Call my google voice number at 805-669-8839". I am hoping to port my old mobile number at some point, but for the next 6 months I'm not going to worry about it.
2011-03-11
Mocking logging in python
from logging import getLogger, StreamHandler
class DirHandler(object):
def __init__(self):
l = getLogger()
l.addHandler(StreamHandler())
def process_dir(self):
l = getLogger()
l.debug('foo')
l.info('bar')
l.warn('baz')
import unittest
from mock import Mock, patch
from logging import RootLogger
target = '%s.getLogger' % __name__
@patch(target)
class TestProcessDir(unittest.TestCase):
def test_logging(self, mock_getLogger):
mock_getLogger.return_value = Mock(spec=RootLogger)
d = DirHandler()
d.process_dir()
method_calls = mock_getLogger.return_value.method_calls
print method_calls
self.assertEqual(0, len(method_calls))
self.assertEqual(None, method_calls[0][0])
if __name__ == '__main__':
unittest.main()
- Where you patch is both critical and potentially confusing. I tried patching logging.getLogger, but since it's already imported, that didn't work. If your code under test does
from foo import bar, then you need to patchmycode.barrather thanfoo.bar. - Giving a spec to Mock proves that your code is at least calling your mock according to it's signature.
mock_logger.method_callsis how to access the method calls. I know it's sad, but it took me a while to figure this one out.
Subscribe to:
Posts (Atom)