def test_filter_filenames(self): extractor = parser.NIB() self.assertEquals( extractor._filter_filenames([ os.path.join("some.nib", "designable.nib"), os.path.join("some.nib", "keyedobjects.nib"), os.path.join("other.nib", "random.nib"), os.path.join("other.nib", "random.other"), ]), [ os.path.join("other.nib", "random.other"), "some.nib", "other.nib", ] ) extractor._filter_filenames = mock.Mock(return_value = []) extractor.extract_strings_from_files([ os.path.join("some.nib", "designable.nib"), os.path.join("some.nib", "keyedobjects.nib"), ]) extractor._filter_filenames.assert_called_with([ os.path.join("some.nib", "designable.nib"), os.path.join("some.nib", "keyedobjects.nib"), ])
def test_get_plist_from_nib_file(self): extractor = parser.NIB() dir = os.path.dirname(__file__) files = [ os.path.join(dir, "test.nib"), os.path.join(dir, "test.xib") ] for file in files: self.assertEquals( extractor._get_plist_from_nib_file(file), NIBTests.sample_nib )
def test_extract_mapping_from_filename(self): extractor = parser.NIB() extractor._get_plist_from_nib_file = mock.Mock( return_value = NIBTests.sample_nib ) mapping = extractor.extract_mapping_from_filename("some_file") self.assertEquals( mapping.string_mapping_dict, { u"SomeString": u"SomeString", u"SomeOtherString": u"SomeOtherString" } )
def test_extract_strings_from_filename(self): extractor = parser.NIB() extractor._get_plist_from_nib_file = mock.Mock( return_value = NIBTests.sample_nib ) extracted_strings = extractor.extract_strings_from_filename("some_file") self.assertEquals( extracted_strings, set([ u"SomeString", u"SomeOtherString" ]) ) for string in extracted_strings: self.assertEquals(type(string), types.UnicodeType)
def test_extracts_strings_from_nib_package(self): params = [] def store_param(param): params.append(param) return [] extractor = parser.NIB() extractor.extract_strings_from_filename = mock.Mock( side_effect = store_param ) extractor.extract_strings_from_files([ os.path.join("some.nib", "designable.nib"), os.path.join("some.nib", "keyedobjects.nib"), os.path.join("other.nib", "random.nib"), ]) self.assertEquals(params, [ "some.nib", "other.nib" ])