Ejemplo n.º 1
0
    def check_postcode_found(self, postcode, expected_result):
        self.m.return_value = [self.valid_entry_one_letter, self.valid_entry_two_letters]
        with patch('geo.open', self.m, create=True):
            g = Geo()
            e, n = g.getEastingAndNorthing(postcode)
            assert_equal((e, n), expected_result)

        postcode_dir = url_for('static', filename='postcodes')
        filename = re.match('([a-z]{1,2})[0-9]', postcode.replace(' ', '')).group(1)
        filename = os.path.join(postcode_dir, filename + '.csv')
        self.m.assert_called_once_with(filename)
Ejemplo n.º 2
0
 def check_postcode_not_found(self, file_content, postcode):
     self.m.return_value = file_content
     with patch('geo.open', self.m, create=True):
         g = Geo()
         with assert_raises(PostcodeNotFoundError):
             g.getEastingAndNorthing(postcode)
Ejemplo n.º 3
0
 def check_invalid_postcode(self, postcode):
     with patch('geo.open', self.m, create=True):
         g = Geo()
         with assert_raises(PostcodeMalformedError):
             g.getEastingAndNorthing(postcode)