# -*- coding: utf-8 -*-
#
# © 2014 Ian Eure
# Author: Ian Eure <ian.eure@gmail.com>
#

import unittest

import yar.devices.matcher as m
import yar.pak as pak

class DeviceMatcherTest(unittest.TestCase):

    devs = pak.load("unipak2b").DEVICES

    def test_extract(self):
        self.assertEqual(("am", "2732dc"),
                         m.extract("am2732dc").groups())
        self.assertEqual(("am", "2732dc"),
                         m.extract("am 2732 dc").groups())
        self.assertEqual(("am", "2732dc"),
                         m.extract("  am 2732 dc  ").groups())

    def test_matches(self):
        print m.matches(self.devs, "am2732dc")

    def test_match(self):
        self.assertRaises(ValueError, m.match, self.devs, "am2732dc")
        self.assertEqual((0x19, 0x24), m.match(self.devs, "am2732"))
        self.assertRaises(ValueError, m.match, self.devs, "2732")


if __name__ == '__main__':
    unittest.main

@@ -615,14 +615,25 @@
     
-print 
+self.assertEqual(
 m.ma
@@ -660,16 +660,814 @@
 2732dc%22)
+,%0A                         (('am', '2732dc'), %5B%5D))%0A%0A        self.assertEqual(%0A            m.matches(self.devs, %22am2732%22),%0A            (('am', '2732'), %5B('AMD', '2732', 'EPROM', 'DIP', 25, 36),%0A                          ('FUJ', '2732', 'EPROM', 'DIP', 25, 36),%0A                          ('INT', '2732', 'EPROM', 'DIP', 25, 36),%0A                          ('MIK', '2732', 'EPROM', 'DIP', 25, 36),%0A                          ('MIT', '2732', 'EPROM', 'DIP', 25, 36),%0A                          ('NAT', '2732', 'EPROM', 'DIP', 25, 36),%0A                          ('NEC', '2732', 'EPROM', 'DIP', 25, 36),%0A                          ('SGS', '2732', 'EPROM', 'DIP', 25, 36),%0A                          ('TEX', '2732', 'EPROM', 'DIP', 189, 36),%0A                          ('TOS', '2732', 'EPROM', 'DIP', 25, 36)%5D))
 %0A%0A    de
@@ -1720,16 +1720,16 @@
 ain__':%0A
-
     unit
@@ -1737,9 +1737,11 @@
 est.main
+()
 %0A

Fix test_device_matcher