view tests/unit.py @ 45:32cf3d3469c3 default tip

assert
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 07 Nov 2013 14:19:06 -0800
parents 77118f83b5b7
children
line wrap: on
line source

#!/usr/bin/env python

"""
unit tests
"""

import os
import sys
import unittest

from commitwatcher import FeedAgentDiff

# globals
here = os.path.dirname(os.path.abspath(__file__))

class CommitWatcherUnitTest(unittest.TestCase):

    # diff -> files mapping, from `lsdiff`
    diff_files = [('41701d2c0341.diff', ['mobile/android/components/HelperAppDialog.js']),
                  ('4e1a3919e741.diff', ["gfx/gl/GLContext.cpp",
                                         "gfx/gl/GLContext.h",
                                         "gfx/layers/Compositor.h",
                                         "gfx/layers/Layers.cpp",
                                         "gfx/layers/Layers.h",
                                         "gfx/layers/basic/BasicCompositor.cpp",
                                         "gfx/layers/basic/BasicCompositor.h",
                                         "gfx/layers/composite/LayerManagerComposite.cpp",
                                         "gfx/layers/composite/LayerManagerComposite.h",
                                         "gfx/layers/d3d11/CompositorD3D11.cpp",
                                         "gfx/layers/d3d11/CompositorD3D11.h",
                                         "gfx/layers/d3d9/CompositorD3D9.cpp",
                                         "gfx/layers/d3d9/CompositorD3D9.h",
                                         "gfx/layers/ipc/CompositorParent.cpp",
                                         "gfx/layers/ipc/CompositorParent.h",
                                         "gfx/layers/ipc/LayerTransactionParent.cpp",
                                         "gfx/layers/opengl/CompositorOGL.cpp",
                                         "gfx/layers/opengl/CompositorOGL.h",
                                         "gfx/thebes/gfx2DGlue.h",
                                         ])
                                        ]
    def test_patch(self):
        """test parsing the files from a patch"""

        for diff, filenames in self.diff_files:
            diff = os.path.join(here, diff)
            files = FeedAgentDiff.lsdiff(diff)
            self.assertEqual(files, set(filenames))

if __name__ == '__main__':
    unittest.main()