def test_format_itis_quantity_unit(self): unit = pywikibot.ItemPage(self.repo, 'Q123') itis = pywikibot.WbQuantity(123, unit=unit, site=self.repo) expected = '123 wd_template_1' self.assertEqual(PreviewItem.format_itis(itis), expected) self.mock_wd_template.assert_called_once_with(unit) self.mock_format_timestring.assert_not_called()
def test_format_itis_statement_item(self): item = pywikibot.ItemPage(self.repo, 'Q123') itis = Statement(item) expected = 'wd_template_1' self.assertEqual(PreviewItem.format_itis(itis), expected) self.mock_wd_template.assert_called_once_with(item) self.mock_format_timestring.assert_not_called()
def test_format_itis_special(self): itis = 'dummy' expected = 'wd_template_1' self.assertEqual( PreviewItem.format_itis(itis, special=True), expected ) self.mock_wd_template.assert_called_once_with(itis, special=True) self.mock_format_timestring.assert_not_called()
def test_format_itis_statement_other(self): itis = Statement('dummy') expected = 'dummy' self.assertEqual( PreviewItem.format_itis(itis), expected ) self.mock_wd_template.assert_not_called() self.mock_format_timestring.assert_not_called()
def test_format_itis_statement_detect_special(self): itis = Statement('novalue', special=True) expected = 'wd_template_1' self.assertEqual( PreviewItem.format_itis(itis), expected ) self.mock_wd_template.assert_called_once_with('novalue', special=True) self.mock_format_timestring.assert_not_called()
def test_format_itis_statement_item(self): item = pywikibot.ItemPage(self.repo, 'Q123') itis = Statement(item) expected = 'wd_template_1' self.assertEqual( PreviewItem.format_itis(itis), expected ) self.mock_wd_template.assert_called_once_with(item) self.mock_format_timestring.assert_not_called()
def test_format_itis_other(self): itis = [1, 2, 3] expected = '[1, 2, 3]' self.assertEqual(PreviewItem.format_itis(itis), expected) self.mock_wd_template.assert_not_called() self.mock_format_timestring.assert_not_called()
def test_format_itis_time(self): itis = pywikibot.WbTime(year=1999) expected = 'formatted_WbTime' self.assertEqual(PreviewItem.format_itis(itis), expected) self.mock_wd_template.assert_not_called() self.mock_format_timestring.assert_called_once()
def test_format_itis_quantity(self): itis = pywikibot.WbQuantity(123, site=self.repo) expected = '123' self.assertEqual(PreviewItem.format_itis(itis), expected) self.mock_wd_template.assert_not_called() self.mock_format_timestring.assert_not_called()
def test_format_itis_statement_detect_special(self): itis = Statement('novalue', special=True) expected = 'wd_template_1' self.assertEqual(PreviewItem.format_itis(itis), expected) self.mock_wd_template.assert_called_once_with('novalue', special=True) self.mock_format_timestring.assert_not_called()
def test_format_itis_statement_other(self): itis = Statement('dummy') expected = 'dummy' self.assertEqual(PreviewItem.format_itis(itis), expected) self.mock_wd_template.assert_not_called() self.mock_format_timestring.assert_not_called()
def test_format_itis_special(self): itis = 'dummy' expected = 'wd_template_1' self.assertEqual(PreviewItem.format_itis(itis, special=True), expected) self.mock_wd_template.assert_called_once_with(itis, special=True) self.mock_format_timestring.assert_not_called()
def test_format_itis_none(self): itis = None expected = 'None' self.assertEqual(PreviewItem.format_itis(itis), expected) self.mock_wd_template.assert_not_called() self.mock_format_timestring.assert_not_called()