Ejemplo n.º 1
0
 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'     
Ejemplo n.º 2
0
 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')
Ejemplo n.º 3
0
 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')
Ejemplo n.º 4
0
 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')
Ejemplo n.º 5
0
 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')
Ejemplo n.º 6
0
 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')
Ejemplo n.º 7
0
 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')
Ejemplo n.º 8
0
 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')
Ejemplo n.º 9
0
 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()
Ejemplo n.º 11
0
 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'
Ejemplo n.º 12
0
 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)
Ejemplo n.º 13
0
 def testReadBusEErrorMessage(self):
     b = bs.Bus()
     self.assertRaisesRegexp(Exception, "^Bus.readBus:\s\s", b.readBus)
Ejemplo n.º 14
0
 def testWriteBusDataFirstReturnValue(self):
     b = bs.Bus()
     d = dt.Data(payload = 3)
     self.assertEqual(b.writeBus(word = d), 1, 'Bus is not instantiated properly')
Ejemplo n.º 15
0
 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')
Ejemplo n.º 16
0
 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')
Ejemplo n.º 17
0
 def testWriteBusStatusFirstReturnValue(self):
     b = bs.Bus()
     s = st.Status(address = 3)
     self.assertEqual(b.writeBus(word = s), 1, 'Bus is not instantiated properly')
Ejemplo n.º 18
0
 def testWriteBusCommandFirstReturnValue(self):
     b = bs.Bus()
     c = com.Command(address = 3)
     self.assertEqual(b.writeBus(word = c), 1, 'Bus is not instantiated properly')
Ejemplo n.º 19
0
 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')
Ejemplo n.º 20
0
 def testInitExists(self):
     b = bs.Bus()
     assert "__init__" in dir(b), 'Method by name __init__ does not exists'
Ejemplo n.º 21
0
 def testWriteBusAlphaNumericErrorMessage(self):
     b = bs.Bus()
     self.assertRaisesRegexp(Exception, "^Bus.writeBus:\s\s", b.writeBus,('a'))
Ejemplo n.º 22
0
 def testReadBusEErrorType(self):
     b = bs.Bus()
     self.assertRaises(ValueError, b.readBus)
Ejemplo n.º 23
0
 def testBusInstantiationReturnType(self):
     b = bs.Bus()
     assert isinstance(b, bs.Bus), 'Bus is not instantiated properly'
Ejemplo n.º 24
0
 def testWriteBusExists(self):
     b = bs.Bus()
     assert "writeBus" in dir(b), 'Method by name writeBus does not exists'
Ejemplo n.º 25
0
 def testWriteBusNoParamErrorType(self):
     b = bs.Bus()
     self.assertRaises(ValueError, b.writeBus)
Ejemplo n.º 26
0
 def testWriteBusNumberErrorMessage(self):
     b = bs.Bus()
     self.assertRaisesRegexp(Exception, "^Bus.writeBus:\s\s", b.writeBus, (1))
Ejemplo n.º 27
0
 def testWriteBusNegativeErrorType(self):
     b = bs.Bus()
     self.assertRaises(ValueError, b.writeBus,(1))
Ejemplo n.º 28
0
 def testReadBusExists(self):
     b = bs.Bus()
     assert "readBus" in dir(b), 'Method by name readBus does not exists'
Ejemplo n.º 29
0
 def testBusInstantiationReturnValue(self):
     b = bs.Bus()
     self.assertEqual(b.bus.size(), 0, 'Bus is not instantiated properly')
Ejemplo n.º 30
0
 def testWriteBusAlphaNumericErrorType(self):
     b = bs.Bus()
     self.assertRaises(ValueError, b.writeBus,('a'))