From 174e4fdf94da8a0bff707849366ec7a152b25275 Mon Sep 17 00:00:00 2001 From: "DSTO\\pivatom" Date: Tue, 18 Dec 2018 10:11:40 +1030 Subject: [PATCH] Add initial tests --- tests/test_hand_recogniser.py | 12 ++++++++++++ tests/test_mqtt_voter.py | 22 ++++++++++++++++++++++ tests/test_vote.py | 26 ++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 tests/test_hand_recogniser.py create mode 100644 tests/test_mqtt_voter.py create mode 100644 tests/test_vote.py diff --git a/tests/test_hand_recogniser.py b/tests/test_hand_recogniser.py new file mode 100644 index 0000000..0137fd8 --- /dev/null +++ b/tests/test_hand_recogniser.py @@ -0,0 +1,12 @@ +import unittest +from GestureRecognition.SimpleHandRecogniser import SimpleHandRecogniser + +class TestSimpleHandRecogniser(unittest.TestCase): + + + + def setUp(self): + self.image_path = "H:\car\GestureRecognition\IMG_0818.png" + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_mqtt_voter.py b/tests/test_mqtt_voter.py new file mode 100644 index 0000000..b76f951 --- /dev/null +++ b/tests/test_mqtt_voter.py @@ -0,0 +1,22 @@ +import unittest +from DecisionSystem.mqttvoter import MqttVoter +from DecisionSystem.vote import Vote + +class TestMqttVoter(unittest.TestCase): + + def test_vote_property(self): + self.assertTrue(self.voter.set_vote(Vote())) + self.assertEquals(self.voter.get_vote(), Vote()) + + def test_invalid_vote_set(self): + self.assertFalse(self.voter.set_vote("Hi")) + + @unittest.skip + def test_submit_vote(self): + pass + + def setUp(self): + self.voter = MqttVoter() + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/test_vote.py b/tests/test_vote.py new file mode 100644 index 0000000..d90a3de --- /dev/null +++ b/tests/test_vote.py @@ -0,0 +1,26 @@ +import unittest +from DecisionSystem.vote import Vote + +# Need to subclass unittest.TestCase to be a test case. +class Test_TestVoteMethods(unittest.TestCase): + + # Test method dec. must start with test + def test_vote_default(self): + self.assertIs(self.vote.vote, None) + + def test_vote_set(self): + self.vote.vote = "Hello" + self.assertEqual(self.vote.vote, "Hello") + + def test_equal_default(self): + self.assertEqual(self.vote, Vote()) + + def test_equal_changed(self): + self.vote.vote = "Hi" + self.assertEqual(self.vote, Vote("Hi")) + + def setUp(self): + self.vote = Vote() + +if __name__ == '__main__': + unittest.main() \ No newline at end of file