Пример #1
0
 def test_discard(self):
     entries = {
         'test_1': MockEntry('test_1'),
         'test_2': MockEntry('test_2')
     }
     entry_set = native._OrderedEntrySet(entries)
     entry_set.discard('test_1')
     self.assertNotIn('test_1', entry_set)
Пример #2
0
 def test_discard(self):
     entries = {
         'test_1': MockEntry('test_1'),
         'test_2': MockEntry('test_2')
     }
     entry_set = native._OrderedEntrySet(entries)
     entry_set.discard('test_1')
     self.assertNotIn('test_1', entry_set)
Пример #3
0
 def test_get(self):
     entries = {
         'test_1': MockEntry('test_1'),
         'test_2': MockEntry('test_2')
     }
     entry_set = native._OrderedEntrySet(entries)
     self.assertEqual(entry_set.get('test_1'), entries['test_1'])
     self.assertIsNone(entry_set.get('test_3'))
     self.assertEqual(entry_set.get('test_3', 5), 5)
Пример #4
0
 def test_init_from_dict(self):
     entries = {
         'test_1': MockEntry('test_1'),
         'test_2': MockEntry('test_2')
     }
     entry_set = native._OrderedEntrySet(entries)
     self.assertEqual(entry_set['test_1'], entries['test_1'])
     self.assertEqual(entry_set['test_2'], entries['test_2'])
     self.assertEqual(len(entry_set), len(entries))
Пример #5
0
 def test_get(self):
     entries = {
         'test_1': MockEntry('test_1'),
         'test_2': MockEntry('test_2')
     }
     entry_set = native._OrderedEntrySet(entries)
     self.assertEqual(entry_set.get('test_1'), entries['test_1'])
     self.assertIsNone(entry_set.get('test_3'))
     self.assertEqual(entry_set.get('test_3', 5), 5)
Пример #6
0
 def test_init_from_dict(self):
     entries = {
         'test_1': MockEntry('test_1'),
         'test_2': MockEntry('test_2')
     }
     entry_set = native._OrderedEntrySet(entries)
     self.assertEqual(entry_set['test_1'], entries['test_1'])
     self.assertEqual(entry_set['test_2'], entries['test_2'])
     self.assertEqual(len(entry_set), len(entries))
Пример #7
0
    def test_clear(self):
        entries = {
            'test_1': MockEntry('test_1'),
            'test_2': MockEntry('test_2')
        }
        entry_set = native._OrderedEntrySet(entries)
        entry_set.clear()

        self.assertEqual(len(entry_set), 0)
        self.assertNotIn('test_1', entry_set)
Пример #8
0
    def test_clear(self):
        entries = {
            'test_1': MockEntry('test_1'),
            'test_2': MockEntry('test_2')
        }
        entry_set = native._OrderedEntrySet(entries)
        entry_set.clear()

        self.assertEqual(len(entry_set), 0)
        self.assertNotIn('test_1', entry_set)
Пример #9
0
    def test_update(self):
        entries = {
            'test_1': MockEntry('test_1'),
            'test_2': MockEntry('test_2')
        }
        entry_set = native._OrderedEntrySet(entries)
        entry_set.update([MockEntry('test_2'), MockEntry('test_3')])

        self.assertEqual(len(entry_set), 3)
        self.assertEqual(entry_set['test_1'], entries['test_1'])
        self.assertNotEqual(entry_set['test_2'], entries['test_2'])
Пример #10
0
    def test_add_and_contains(self):
        entry_set = native._OrderedEntrySet()
        entry_set.add_entry(MockEntry('def'))
        entry_set.add_entry(MockEntry('abc'))
        entry_set.add_entry(MockEntry('ghi'))

        self.assertIn('def', entry_set)
        self.assertIn('ghi', entry_set)
        self.assertNotIn('klm', entry_set)
        self.assertEqual(len(entry_set), 3)

        # Check that it is ordered
        self.assertEqual([entry.id for entry in entry_set],
                         ['def', 'abc', 'ghi'])
Пример #11
0
    def test_update(self):
        entries = {
            'test_1': MockEntry('test_1'),
            'test_2': MockEntry('test_2')
        }
        entry_set = native._OrderedEntrySet(entries)
        entry_set.update([
            MockEntry('test_2'),
            MockEntry('test_3')
        ])

        self.assertEqual(len(entry_set), 3)
        self.assertEqual(entry_set['test_1'], entries['test_1'])
        self.assertNotEqual(entry_set['test_2'], entries['test_2'])
Пример #12
0
    def test_add_and_contains(self):
        entry_set = native._OrderedEntrySet()
        entry_set.add_entry(MockEntry('def'))
        entry_set.add_entry(MockEntry('abc'))
        entry_set.add_entry(MockEntry('ghi'))

        self.assertIn('def', entry_set)
        self.assertIn('ghi', entry_set)
        self.assertNotIn('klm', entry_set)
        self.assertEqual(len(entry_set), 3)

        # Check that it is ordered
        self.assertEqual(
            [entry.id for entry in entry_set], ['def', 'abc', 'ghi'])