blob: eab886c57f3b9a50b74dc1bce1817d7b973c98e7 [file] [log] [blame]
David Rochberg7c79a812011-01-19 14:24:45 -05001#!/usr/bin/python
2
3# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Unit tests for gmerge."""
8
9import gmerge
10import unittest
11
12class Flags(object):
13 def __init__(self, dictionary):
14 self.__dict__.update(dictionary)
15
16
17class GMergeTest(unittest.TestCase):
18 """Test for gmerge."""
19
20 def setUp(self):
21 self.lsb_release_lines = [
22 'CHROMEOS_RELEASE_BOARD=x86-mario\r\n',
23 'CHROMEOS_DEVSERVER=http://localhost:8080/\n']
24
25 def testLsbRelease(self):
26 merger = gmerge.GMerger(self.lsb_release_lines)
27 self.assertEqual({'CHROMEOS_RELEASE_BOARD': 'x86-mario',
28 'CHROMEOS_DEVSERVER': 'http://localhost:8080/'},
29 merger.lsb_release)
30
31 def testPostData(self):
32 gmerge.FLAGS = Flags({'use': 'a b c d +e',
33 'accept_stable': 'blah'})
34
35 merger = gmerge.GMerger(self.lsb_release_lines)
36 self.assertEqual(
37 'use=a+b+c+d+%2Be&pkg=package_name&board=x86-mario&accept_stable=blah',
38 merger.GeneratePackageRequest('package_name'))
39
40
41if __name__ == '__main__':
42 unittest.main()