def testScenario1And4(self): rtAddress = 10 r = rt.RemoteTerminal(address = rtAddress) c = com.Command(address = r.getAddress()) c.setToModeCommand(mode = com.Command.transmitStatusWord) bus = bs.Bus() bus.writeBus(word = c) rtResponse = r.readBus(bus = bus) rWord = rtResponse.readBus() assert isinstance(rWord, st.Status), 'Resulting word is not status word' try: self.assertEqual(rWord.isServiceRequested(), False, 'RT wants to communicate') print 'Test scenario 1 was tested' except Exception: print 'Test scenario 4 was tested' self.assertEqual(rWord.isServiceRequested(), True, 'RT does not want to communicate') c1 = com.Command(address = r.getAddress()) c1.setToModeCommand(mode = com.Command.transmitVectorWord) bus = bs.Bus() bus.writeBus(word = c1) rtResponse = r.readBus(bus = bus) rWord = rtResponse.readBus() assert isinstance(rWord, st.Status), 'Resulting word is not status word' cWord = rtResponse.readBus() assert isinstance(cWord, com.Command), 'Resulting word is not command word'
def testWriteBusStatusThirdReturnValue(self): b = bs.Bus() s1 = st.Status(address = 3) b.writeBus(word = s1) s2 = st.Status(address = 5) b.writeBus(word = s2) s3 = st.Status(address = 6) self.assertEqual(b.writeBus(word = s3), 3, 'Bus is not instantiated properly')
def testWriteBusCommandThirdReturnValue(self): b = bs.Bus() c1 = com.Command(address = 3) b.writeBus(word = c1) c2 = com.Command(address = 5) b.writeBus(word = c2) c3 = com.Command(address = 6) self.assertEqual(b.writeBus(word = c3), 3, 'Bus is not instantiated properly')
def testWriteBusDataThirdReturnValue(self): b = bs.Bus() d1 = dt.Data(payload = 3) b.writeBus(word = d1) d2 = dt.Data(payload = 5) b.writeBus(word = d2) d3 = dt.Data(payload = 6) self.assertEqual(b.writeBus(word = d3), 3, 'Bus is not instantiated properly')
def testReadBusNEStatusChange(self): b = bs.Bus() s1 = st.Status(address = 3) b.writeBus(word = s1) s2 = st.Status(address = 5) b.writeBus(word = s2) s3 = st.Status(address = 6) b.writeBus(word = s3) self.assertEqual(b.readBus(), s1, 'readBus does not work properly')
def testWriteBusStatusSecondStateChange(self): b = bs.Bus() s1 = st.Status(address = 3) b.writeBus(word = s1) s2 = st.Status(address = 5) b.writeBus(word = s2) self.assertEqual(b.bus.size(), 2, 'Bus is not instantiated properly') self.assertEqual(b.bus.dequeue(), s1, 'Bus is not instantiated properly') self.assertEqual(b.bus.dequeue(), s2, 'Bus is not instantiated properly')
def testWriteBusCommandSecondStateChange(self): b = bs.Bus() c1 = com.Command(address = 3) b.writeBus(word = c1) c2 = com.Command(address = 5) b.writeBus(word = c2) self.assertEqual(b.bus.size(), 2, 'Bus is not instantiated properly') self.assertEqual(b.bus.dequeue(), c1, 'Bus is not instantiated properly') self.assertEqual(b.bus.dequeue(), c2, 'Bus is not instantiated properly')
def testWriteBusDataSecondStateChange(self): b = bs.Bus() d1 = dt.Data(payload = 3) b.writeBus(word = d1) d2 = dt.Data(payload = 5) b.writeBus(word = d2) self.assertEqual(b.bus.size(), 2, 'Bus is not instantiated properly') self.assertEqual(b.bus.dequeue(), d1, 'Bus is not instantiated properly') self.assertEqual(b.bus.dequeue(), d2, 'Bus is not instantiated properly')
def testReadBusNEReturnType(self): b = bs.Bus() s1 = st.Status(address = 3) b.writeBus(word = s1) s2 = st.Status(address = 5) b.writeBus(word = s2) s3 = st.Status(address = 6) b.writeBus(word = s3) assert isinstance(b.readBus(), st.Status), 'readBus does not work properly'
def setUp(self): self.sat = sat.Satellite() self.rt1 = remT.RemoteTerminal(1) self.rt2 = remT.RemoteTerminal(2) self.rt3 = remT.RemoteTerminal(3) self.rt4 = remT.RemoteTerminal(4) self.sat.addRemoteTerminal(self.rt1) self.sat.addRemoteTerminal(self.rt2) self.sat.addRemoteTerminal(self.rt3) self.bus = b.Bus()
def testScenario2(self): rtAddress = 5 rtSubAddress = 10 r = rt.RemoteTerminal(address = rtAddress) wordCount = r.getAddress() c = com.Command(address = r.getAddress()) c.setToCommandWord(address = rtSubAddress) c.setReceiveCommand() c.setWordCount(count = wordCount) bus = bs.Bus() bus.writeBus(word = c) for index in range(wordCount): bus.writeBus(word = dt.Data(payload = index)) rtResponse = r.readBus(bus = bus) rWord = rtResponse.readBus() assert isinstance(rWord, st.Status), 'Resulting word is not status word'
def testScenario3(self): rtAddress = 8 rtSubAddress = 14 r = rt.RemoteTerminal(address = rtAddress) wordCount = r.getAddress() c = com.Command(address = r.getAddress()) c.setToCommandWord(address = rtSubAddress) c.setTransmitCommand() c.setWordCount(count = wordCount) bus = bs.Bus() bus.writeBus(word = c) rtResponse = r.readBus(bus = bus) rWord = rtResponse.readBus() assert isinstance(rWord, st.Status), 'Resulting word is not status word' self.assertEqual(rWord.isServiceRequested(), False, 'RT wants to communicate') for i in range(r.getAddress()): dWord = rtResponse.readBus() assert isinstance(dWord, dt.Data), 'Resulting word is not data word' self.assertEqual(dWord.getContent(), i, 'Data word not delivered in proper order') self.assertRaises(ValueError, rtResponse.readBus)
def testReadBusEErrorMessage(self): b = bs.Bus() self.assertRaisesRegexp(Exception, "^Bus.readBus:\s\s", b.readBus)
def testWriteBusDataFirstReturnValue(self): b = bs.Bus() d = dt.Data(payload = 3) self.assertEqual(b.writeBus(word = d), 1, 'Bus is not instantiated properly')
def testWriteBusDataFirstStateChange(self): b = bs.Bus() d = dt.Data(payload = 3) b.writeBus(word = d) self.assertEqual(b.bus.size(), 1, 'Bus is not instantiated properly') self.assertEqual(b.bus.dequeue(), d, 'Bus is not instantiated properly')
def testWriteBusStatusFirstStateChange(self): b = bs.Bus() s = st.Status(address = 3) b.writeBus(word = s) self.assertEqual(b.bus.size(), 1, 'Bus is not instantiated properly') self.assertEqual(b.bus.dequeue(), s, 'Bus is not instantiated properly')
def testWriteBusStatusFirstReturnValue(self): b = bs.Bus() s = st.Status(address = 3) self.assertEqual(b.writeBus(word = s), 1, 'Bus is not instantiated properly')
def testWriteBusCommandFirstReturnValue(self): b = bs.Bus() c = com.Command(address = 3) self.assertEqual(b.writeBus(word = c), 1, 'Bus is not instantiated properly')
def testWriteBusCommandFirstStateChange(self): b = bs.Bus() c = com.Command(address = 3) b.writeBus(word = c) self.assertEqual(b.bus.size(), 1, 'Bus is not instantiated properly') self.assertEqual(b.bus.dequeue(), c, 'Bus is not instantiated properly')
def testInitExists(self): b = bs.Bus() assert "__init__" in dir(b), 'Method by name __init__ does not exists'
def testWriteBusAlphaNumericErrorMessage(self): b = bs.Bus() self.assertRaisesRegexp(Exception, "^Bus.writeBus:\s\s", b.writeBus,('a'))
def testReadBusEErrorType(self): b = bs.Bus() self.assertRaises(ValueError, b.readBus)
def testBusInstantiationReturnType(self): b = bs.Bus() assert isinstance(b, bs.Bus), 'Bus is not instantiated properly'
def testWriteBusExists(self): b = bs.Bus() assert "writeBus" in dir(b), 'Method by name writeBus does not exists'
def testWriteBusNoParamErrorType(self): b = bs.Bus() self.assertRaises(ValueError, b.writeBus)
def testWriteBusNumberErrorMessage(self): b = bs.Bus() self.assertRaisesRegexp(Exception, "^Bus.writeBus:\s\s", b.writeBus, (1))
def testWriteBusNegativeErrorType(self): b = bs.Bus() self.assertRaises(ValueError, b.writeBus,(1))
def testReadBusExists(self): b = bs.Bus() assert "readBus" in dir(b), 'Method by name readBus does not exists'
def testBusInstantiationReturnValue(self): b = bs.Bus() self.assertEqual(b.bus.size(), 0, 'Bus is not instantiated properly')
def testWriteBusAlphaNumericErrorType(self): b = bs.Bus() self.assertRaises(ValueError, b.writeBus,('a'))