File: values.py

package info (click to toggle)
pytagsfs 0.9.2-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 976 kB
  • ctags: 1,858
  • sloc: python: 10,656; xml: 543; makefile: 45
file content (43 lines) | stat: -rw-r--r-- 1,596 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Copyright (c) 2008 Forest Bond.
# This file is part of the pytagsfs software package.
#
# pytagsfs is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License version 2 as published by the Free
# Software Foundation.
#
# A copy of the license has been included in the COPYING file.

from unittest import TestCase

from pytagsfs.values import Values

from manager import manager


class TestValues(TestCase):
    def test_diff2_with_value_removal(self):
        old = Values({'a': [u'foo'], 'b': [u'baz']})
        new = Values({'b': [u'baz']})
        self.assertEqual(Values.diff2(old, new), Values({'a': []}))

    def test_diff3_with_partial_value_removal(self):
        base = Values({'a': [u'foo', u'bar'], 'b': [u'baz'], 'd': [u'qux']})
        old = Values({'a': [u'foo'], 'b': [u'baz']})
        new = Values({'b': [u'baz']})
        self.assertEqual(Values.diff3(base, old, new), Values({'a': [u'bar']}))

    def test_diff2_with_value_change(self):
        old = Values({'a': [u'foo'], 'b': [u'baz']})
        new = Values({'a': [u'boink'], 'b': [u'baz']})
        self.assertEqual(Values.diff2(old, new), Values({'a': [u'boink']}))

    def test_diff3_with_partial_value_change(self):
        base = Values({'a': [u'foo', u'bar'], 'b': [u'baz'], 'd': [u'qux']})
        old = Values({'a': [u'foo'], 'b': [u'baz']})
        new = Values({'a': [u'boink'], 'b': [u'baz']})
        self.assertEqual(
          Values.diff3(base, old, new),
          Values({'a': [u'bar', u'boink']}),
        )

manager.add_test_case_class(TestValues)