Esempio n. 1
0
    def test_keep_fields(self):
        item = self.add_item_fixture(year=2016, comments=u'test comment')
        self.config['zero']['keep_fields'] = [u'year']
        self.config['zero']['fields'] = None
        self.config['zero']['update_database'] = True

        tags = {
            'comments': u'test comment',
            'year': 2016,
        }
        self.load_plugins('zero')

        z = ZeroPlugin()
        z.write_event(item, item.path, tags)
        self.assertEqual(tags['comments'], None)
        self.assertEqual(tags['year'], 2016)
Esempio n. 2
0
    def test_fields_removes_preserved_tags(self):
        self.config['zero']['fields'] = [u'year id']
        self.config['zero']['update_database'] = True

        z = ZeroPlugin()

        self.assertNotIn('id', z.fields_to_progs)
Esempio n. 3
0
    def test_keep_fields(self):
        item = self.add_item_fixture(year=2016, comments=u'test comment')
        self.config['zero']['keep_fields'] = [u'year']
        self.config['zero']['fields'] = None
        self.config['zero']['update_database'] = True

        tags = {
            'comments': u'test comment',
            'year': 2016,
        }
        self.load_plugins('zero')

        z = ZeroPlugin()
        z.write_event(item, item.path, tags)
        self.assertEqual(tags['comments'], None)
        self.assertEqual(tags['year'], 2016)
Esempio n. 4
0
 def test_no_patterns(self):
     v = {'comments': 'test comment', 'day': 13, 'month': 3, 'year': 2012}
     i = Item(v)
     z = ZeroPlugin()
     z.debug = False
     z.fields = ['comments', 'month', 'day']
     z.patterns = {'comments': ['.'], 'month': ['.'], 'day': ['.']}
     z.write_event(i)
     self.assertEqual(i.comments, '')
     self.assertEqual(i.day, 0)
     self.assertEqual(i.month, 0)
     self.assertEqual(i.year, 2012)
Esempio n. 5
0
 def test_patterns(self):
     v = {'comments': 'from lame collection, ripped by eac', 'year': 2012}
     i = Item(v)
     z = ZeroPlugin()
     z.debug = False
     z.fields = ['comments', 'year']
     z.patterns = {
         'comments': 'eac lame'.split(),
         'year': '2098 2099'.split()
     }
     z.write_event(i)
     self.assertEqual(i.comments, '')
     self.assertEqual(i.year, 2012)
Esempio n. 6
0
    def test_patterns(self):
        z = ZeroPlugin()
        z.debug = False
        z.fields = ['comments', 'year']
        z.patterns = {'comments': u'eac lame'.split(),
                      'year': u'2098 2099'.split()}

        tags = {
            'comments': u'from lame collection, ripped by eac',
            'year': 2012,
        }
        z.write_event(None, None, tags)
        self.assertEqual(tags['comments'], None)
        self.assertEqual(tags['year'], 2012)
Esempio n. 7
0
 def test_patterns(self):
     v = {'comments' : 'from lame collection, ripped by eac',
          'year' : 2012}
     i=Item(v)
     z = ZeroPlugin()
     z.debug = False
     z.fields = ['comments', 'year']
     z.patterns = {'comments': 'eac lame'.split(),
                   'year': '2098 2099'.split()}
     z.write_event(i)
     self.assertEqual(i.comments, '')
     self.assertEqual(i.year, 2012)
Esempio n. 8
0
 def test_no_patterns(self):
     i = Item(
         comments='test comment',
         day=13,
         month=3,
         year=2012,
     )
     z = ZeroPlugin()
     z.debug = False
     z.fields = ['comments', 'month', 'day']
     z.patterns = {'comments': ['.'], 'month': ['.'], 'day': ['.']}
     z.write_event(i)
     self.assertEqual(i.comments, '')
     self.assertEqual(i.day, 0)
     self.assertEqual(i.month, 0)
     self.assertEqual(i.year, 2012)
Esempio n. 9
0
 def test_no_patterns(self):
     tags = {
         'comments': 'test comment',
         'day': 13,
         'month': 3,
         'year': 2012,
     }
     z = ZeroPlugin()
     z.debug = False
     z.fields = ['comments', 'month', 'day']
     z.patterns = {'comments': ['.'], 'month': ['.'], 'day': ['.']}
     z.write_event(None, None, tags)
     self.assertEqual(tags['comments'], None)
     self.assertEqual(tags['day'], None)
     self.assertEqual(tags['month'], None)
     self.assertEqual(tags['year'], 2012)
Esempio n. 10
0
    def test_patterns(self):
        z = ZeroPlugin()
        z.debug = False
        z.fields = ['comments', 'year']
        z.patterns = {'comments': u'eac lame'.split(),
                      'year': u'2098 2099'.split()}

        tags = {
            'comments': u'from lame collection, ripped by eac',
            'year': 2012,
        }
        z.write_event(None, None, tags)
        self.assertEqual(tags['comments'], None)
        self.assertEqual(tags['year'], 2012)
Esempio n. 11
0
 def test_no_patterns(self):
     v = {'comments' : 'test comment',
          'day' : 13,
          'month' : 3,
          'year' : 2012}
     i=Item(v)
     z = ZeroPlugin()
     z.debug = False
     z.fields = ['comments', 'month', 'day']
     z.patterns = {'comments': ['.'],
                   'month': ['.'],
                   'day': ['.']}
     z.write_event(i)
     self.assertEqual(i.comments, '')
     self.assertEqual(i.day, 0)
     self.assertEqual(i.month, 0)
     self.assertEqual(i.year, 2012)
Esempio n. 12
0
 def test_no_patterns(self):
     tags = {
         'comments': u'test comment',
         'day': 13,
         'month': 3,
         'year': 2012,
     }
     z = ZeroPlugin()
     z.debug = False
     z.fields = ['comments', 'month', 'day']
     z.patterns = {'comments': [u'.'],
                   'month': [u'.'],
                   'day': [u'.']}
     z.write_event(None, None, tags)
     self.assertEqual(tags['comments'], None)
     self.assertEqual(tags['day'], None)
     self.assertEqual(tags['month'], None)
     self.assertEqual(tags['year'], 2012)
Esempio n. 13
0
 def test_no_patterns(self):
     i = Item(
         comments='test comment',
         day=13,
         month=3,
         year=2012,
     )
     z = ZeroPlugin()
     z.debug = False
     z.fields = ['comments', 'month', 'day']
     z.patterns = {'comments': ['.'],
                   'month': ['.'],
                   'day': ['.']}
     z.write_event(i)
     self.assertEqual(i.comments, '')
     self.assertEqual(i.day, 0)
     self.assertEqual(i.month, 0)
     self.assertEqual(i.year, 2012)
Esempio n. 14
0
 def test_singleton(self):
     z1 = ZeroPlugin()
     z2 = ZeroPlugin()
     self.assertTrue(z1 is z2)