コード例 #1
0
    def test_clean(self):
        """Tests the clean method of the database"""
        self.test_db.add(Gas("test"))
        self.test_db.add(Gas("test"))
        self.assertEqual(len(self.test_db.get_records()), 2)

        self.test_db.clean()
        self.assertEqual(len(self.test_db.get_records()), 0)
コード例 #2
0
    def test_add(self):
        """Tests the add method of the database"""

        original_size = len(self.test_db.get_records())
        self.test_db.add(Gas("test", self.__MY_DATE))

        records = self.test_db.get_records()
        self.assertEqual(len(records), original_size + 1)
        self.assertEqual(records[-1], Gas("test", self.__MY_DATE))
コード例 #3
0
    def test_add_wo_date(self):
        """Tests the add method of the database"""

        original_size = len(self.test_db.get_records())
        new_date = self.test_db.add(Gas("test")).date

        records = self.test_db.get_records()
        self.assertEqual(len(records), original_size + 1)
        self.assertEqual(records[-1], Gas("test", new_date))
コード例 #4
0
    def test__ne__notimplemented(self):
        """Tests the ne method for the Gas object"""

        self.assertNotEqual(Gas("test", self.__MY_DATE), "Testing string")
コード例 #5
0
    def test__ne__(self):
        """Tests the ne method for the Gas object"""

        self.assertNotEqual(Gas("test", self.__MY_DATE), Gas("test"))
コード例 #6
0
    def test__eq__(self):
        """Tests the eq method for the Gas object"""

        self.assertEqual(Gas("test", self.__MY_DATE),
                         Gas("test", self.__MY_DATE))
コード例 #7
0
    def test__str__(self):
        """Tests the str method for the Gas object"""

        self.assertEqual(str(Gas("test", self.__MY_DATE)),
                         "User: {}\nDate: {}".format("test", self.__MY_DATE))
コード例 #8
0
    def test__repr__(self):
        """Tests the repr method for the Gas object"""

        self.assertEqual(repr(Gas("test", self.__MY_DATE)),
                         "{}|{}".format("test", self.__MY_DATE))