blob: 9e28ed7f3c0125beb881d603fb05e43de23092d3 [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
Chris Sosa37b217a2011-04-13 21:03:519import os
David Rochberg7c79a812011-01-19 19:24:4510import unittest
11
Gilad Arnoldabb352e2012-09-23 08:24:2712import gmerge
13
14
David Rochberg7c79a812011-01-19 19:24:4515class Flags(object):
16 def __init__(self, dictionary):
17 self.__dict__.update(dictionary)
18
19
20class GMergeTest(unittest.TestCase):
21 """Test for gmerge."""
22
23 def setUp(self):
24 self.lsb_release_lines = [
25 'CHROMEOS_RELEASE_BOARD=x86-mario\r\n',
26 'CHROMEOS_DEVSERVER=http://localhost:8080/\n']
27
28 def testLsbRelease(self):
29 merger = gmerge.GMerger(self.lsb_release_lines)
30 self.assertEqual({'CHROMEOS_RELEASE_BOARD': 'x86-mario',
31 'CHROMEOS_DEVSERVER': 'http://localhost:8080/'},
32 merger.lsb_release)
33
34 def testPostData(self):
Chris Sosae66c2652011-04-13 21:55:2535 old_env = os.environ
36 os.environ = {}
Chris Sosa37b217a2011-04-13 21:03:5137 os.environ['USE'] = 'a b c d +e'
David Jamesbf0db102011-06-02 20:06:3838 gmerge.FLAGS = Flags({'accept_stable': 'blah',
39 'deep': False,
40 'usepkg': False})
David Rochberg7c79a812011-01-19 19:24:4541
42 merger = gmerge.GMerger(self.lsb_release_lines)
43 self.assertEqual(
David Jamesbf0db102011-06-02 20:06:3844 'use=a+b+c+d+%2Be&board=x86-mario&deep=&pkg=package_name&usepkg=&'
45 'accept_stable=blah',
David Rochberg7c79a812011-01-19 19:24:4546 merger.GeneratePackageRequest('package_name'))
Chris Sosae66c2652011-04-13 21:55:2547 os.environ = old_env
David Rochberg7c79a812011-01-19 19:24:4548
49
50if __name__ == '__main__':
51 unittest.main()