blob: 833b7df0ee6325a85fed4efe292bf7560c2dad47 [file] [log] [blame]
David Rochberg7c79a812011-01-19 19:24:451#!/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
Chris Sosa37b217a2011-04-13 21:03:5110import os
David Rochberg7c79a812011-01-19 19:24:4511import unittest
12
13class Flags(object):
14 def __init__(self, dictionary):
15 self.__dict__.update(dictionary)
16
17
18class GMergeTest(unittest.TestCase):
19 """Test for gmerge."""
20
21 def setUp(self):
22 self.lsb_release_lines = [
23 'CHROMEOS_RELEASE_BOARD=x86-mario\r\n',
24 'CHROMEOS_DEVSERVER=http://localhost:8080/\n']
25
26 def testLsbRelease(self):
27 merger = gmerge.GMerger(self.lsb_release_lines)
28 self.assertEqual({'CHROMEOS_RELEASE_BOARD': 'x86-mario',
29 'CHROMEOS_DEVSERVER': 'http://localhost:8080/'},
30 merger.lsb_release)
31
32 def testPostData(self):
Chris Sosae66c2652011-04-13 21:55:2533 old_env = os.environ
34 os.environ = {}
Chris Sosa37b217a2011-04-13 21:03:5135 os.environ['USE'] = 'a b c d +e'
David Jamesbf0db102011-06-02 20:06:3836 gmerge.FLAGS = Flags({'accept_stable': 'blah',
37 'deep': False,
38 'usepkg': False})
David Rochberg7c79a812011-01-19 19:24:4539
40 merger = gmerge.GMerger(self.lsb_release_lines)
41 self.assertEqual(
David Jamesbf0db102011-06-02 20:06:3842 'use=a+b+c+d+%2Be&board=x86-mario&deep=&pkg=package_name&usepkg=&'
43 'accept_stable=blah',
David Rochberg7c79a812011-01-19 19:24:4544 merger.GeneratePackageRequest('package_name'))
Chris Sosae66c2652011-04-13 21:55:2545 os.environ = old_env
David Rochberg7c79a812011-01-19 19:24:4546
47
48if __name__ == '__main__':
49 unittest.main()