コード例 #1
0
    def test_make_entry_new_no_frequency_with_previous_no_value(self):
        entry = None
        previous = {'name': 'a name', 'frequency': 0}
        expected = None

        result = MappingList.make_entry('a name', entry, 0, previous)
        self.assertEquals(result, expected)
コード例 #2
0
    def setUp(self):
        super(TestMappingListBaseWithList, self).setUp()

        self.mapping_list = MappingList(page='prefix/page_name',
                                        parameters=['A'],
                                        header_template='{{header_t}}',
                                        row_template_name='row_t')
コード例 #3
0
    def test_make_entry_new_no_entry(self):
        entry = None
        previous = None
        expected = self.base_format
        expected['name'] = 'a name'
        expected['frequency'] = 2

        result = MappingList.make_entry('a name', entry, 2, previous)
        self.assertEquals(result, expected)
コード例 #4
0
def make_keywords_list(mapping_dir=None, mapping_root=None):
    """Create a MappingList object for keywords."""
    mapping_dir = mapping_dir or MAPPINGS_DIR
    mapping_root = mapping_root or 'dummy'
    parameters = ['name', 'category', 'frequency']
    header = '{{User:André Costa (WMSE)/mapping-head|category=}}'
    return MappingList(page='{}/keywords'.format(mapping_root),
                       parameters=parameters,
                       header_template=header,
                       mapping_dir=mapping_dir)
コード例 #5
0
def make_ethnic_list(mapping_dir=None, mapping_root=None):
    """Create a MappingList object for ethinc groups."""
    mapping_dir = mapping_dir or MAPPINGS_DIR
    mapping_root = mapping_root or 'dummy'
    parameters = ['name', 'more', 'category', 'wikidata', 'frequency']
    header = ('{{User:André Costa (WMSE)/mapping-head'
              '|category=|wikidata=}}')
    return MappingList(page='{}/ethnic_groups'.format(mapping_root),
                       parameters=parameters,
                       header_template=header,
                       mapping_dir=mapping_dir)
コード例 #6
0
    def test_make_entry_new_with_previous_and_entry(self):
        entry = {'more': 'foo'}
        previous = {'name': 'a name', 'frequency': 0, 'bar': 'foobar'}
        expected = {
            'name': 'a name',
            'more': 'foo',
            'bar': 'foobar',
            'frequency': 2
        }

        result = MappingList.make_entry('a name', entry, 2, previous)
        self.assertEquals(result, expected)
コード例 #7
0
def make_people_list(mapping_dir=None, mapping_root=None):
    """Create a MappingList object for people."""
    mapping_dir = mapping_dir or MAPPINGS_DIR
    mapping_root = mapping_root or 'dummy'
    parameters = ['name', 'more', 'creator', 'category', 'wikidata', 'other',
                  'frequency']
    header = ('{{User:André Costa (WMSE)/mapping-head'
              '|category=|creator=|wikidata=|other=leftover comments}}')
    return MappingList(
        page='{}/people'.format(mapping_root),
        parameters=parameters,
        header_template=header,
        mapping_dir=mapping_dir)
コード例 #8
0
 def test_init_all_args(self):
     ml = MappingList(
         page='prefix/page_name',
         parameters=['A', 'b'],
         header_template='{{header_t}}',
         row_template_name='row_t',
         site='a site',
         mapping_dir='a dir',
         wikitext_dir='b dir',
     )
     self.mock_create_dir.assert_has_calls(
         [mock.call('a dir'), mock.call('b dir')])
     self.mock_construct_page.assert_called_once_with(
         'a site', 'prefix/page_name')
     self.assertEquals(ml.page_name, 'page_name')
     self.assertEquals(ml.page, 'pwb.Page')
     self.assertEquals(ml.parameters, OrderedDict([('A', 'A'), ('b', 'b')]))
     self.assertEquals(ml.header_template, '{{header_t}}')
     self.assertEquals(ml.row_template, 'row_t')
コード例 #9
0
 def test_make_entry_empty(self):
     result = MappingList.make_entry('a name', None, 0, None)
     self.assertEquals(result, None)
コード例 #10
0
 def test_init_default_row(self):
     ml = MappingList(page='prefix/page_name', parameters=['A', 'b'])
     self.assertEquals(ml.row_template,
                       'User:André Costa (WMSE)/mapping-row')
コード例 #11
0
 def test_init_dict_parameters(self):
     ml = MappingList(page='prefix/page_name',
                      parameters=OrderedDict([('A', 'A'), ('B', 'b')]),
                      row_template_name='row_t')
     self.assertEquals(ml.parameters, OrderedDict([('A', 'A'), ('B', 'b')]))