Beispiel #1
0
    def tast_remove_service(self):
        """Tests that removing services from database is done correctly"""
        database = Database()

        for key, value in self.services.items():
            database.add_service(key, value[0])

        count = len(self.services)
        for key in self.services.keys():
            database.remove_service(key)
            count -= 1
            self.assertEqual(len(database.services), count)
        self.assertEqual(len(database.services), 0)
        self.assertEqual(database.get_tags(), set())
Beispiel #2
0
    def test_add_service(self):
        """Tests that adding services into database occurs correctly"""
        database = Database()

        count = 0
        self.assertEqual(len(database.services), count)

        tags = set()
        self.assertEqual(database.get_tags(), tags)

        for key, value in self.services.items():
            database.add_service(key, value[0])
            count += 1
            self.assertEqual(len(database.services), count)
            tags = tags | set(value[0].split(','))
            self.assertEqual(database.get_tags(), tags)

        self.assertEqual(count, len(self.services))
Beispiel #3
0
 def test_add_existing_service(self):
     """Tests that adding services into database fails if service is already present"""
     database = Database()
     for key, value in self.services.items():
         database.add_service(key, value[0])
         self.assertRaises(ValueError, database.add_service, key, value[0])