Exemplo n.º 1
0
    def test_override(self):
        self.comp.create_table()
        self.comp.save()
        # Test if component seems to be new, so the update mechanism is used
        comp3 = Component('name', '/path/to/exe3', 'hash3')

        def yes(msg):
            return 'y'

        def no(msg):
            return 'n'

        # override yes
        comp3._input = yes
        comp3.save()
        comp_db = Component.get_exactly('name')
        self.assertEqual(comp3.c_exe, comp_db.c_exe)
        self.assertEqual(comp3.c_exe_hash, comp_db.c_exe_hash)

        # override no
        comp4 = Component('name', '/path/to/exe4', 'hash4')
        comp4._input = no
        comp4.save()
        comp_db = Component.get_exactly('name')
        self.assertNotEqual(comp4.c_exe, comp_db.c_exe)
        self.assertNotEqual(comp4.c_exe_hash, comp_db.c_exe_hash)
        self.assertEqual(comp3.c_exe, comp_db.c_exe)
        self.assertEqual(comp3.c_exe_hash, comp_db.c_exe_hash)
Exemplo n.º 2
0
    def test_override(self):
        self.comp.create_table()
        self.comp.save()
        # Test if component seems to be new, so the update mechanism is used
        comp3 = Component('name', '/path/to/exe3', 'hash3')

        def yes(msg):
            return 'y'

        def no(msg):
            return 'n'
        # override yes
        comp3._input = yes
        comp3.save()
        comp_db = Component.get_exactly('name')
        self.assertEqual(comp3.c_exe, comp_db.c_exe)
        self.assertEqual(comp3.c_exe_hash, comp_db.c_exe_hash)

        # override no
        comp4 = Component('name', '/path/to/exe4', 'hash4')
        comp4._input = no
        comp4.save()
        comp_db = Component.get_exactly('name')
        self.assertNotEqual(comp4.c_exe, comp_db.c_exe)
        self.assertNotEqual(comp4.c_exe_hash, comp_db.c_exe_hash)
        self.assertEqual(comp3.c_exe, comp_db.c_exe)
        self.assertEqual(comp3.c_exe_hash, comp_db.c_exe_hash)
Exemplo n.º 3
0
 def test_add(self):
     """ depends kind of the previous tests, checks only if the database
     entry it really done and the file is moved to the storage
     """
     insert = Component.add(self.component)
     output = Component.get_exactly("example")
     self.assertEqual(insert, output)
     # check if component is stored.
     import os
     self.assertTrue(os.path.isfile(os.path.join(Database.store,
                                                 'example.tgz')))
Exemplo n.º 4
0
 def test_add(self):
     """ depends kind of the previous tests, checks only if the database
     entry it really done and the file is moved to the storage
     """
     insert = Component.add(self.component)
     output = Component.get_exactly("example")
     self.assertEqual(insert, output)
     # check if component is stored.
     import os
     self.assertTrue(
         os.path.isfile(os.path.join(Database.store, 'example.tgz')))
Exemplo n.º 5
0
    def test_update(self):
        """ Checks if data can be changed
        """
        self.comp.create_table()
        self.comp.save()
        self.comp.c_exe = "updatedexe"
        self.comp.save()

        # raw database check
        self.cursor.execute("SELECT * FROM Component;")
        result = self.cursor.fetchall()
        self.assertEqual(len(result), 1, "too much or too less objects")
        self.cursor.execute("SELECT * FROM Component;")
        res = self.cursor.fetchone()
        res = tuple(res)
        self.assertEqual(res[3], "updatedexe",
                         "Seems not to be updated correctly")

        # Object oriented check
        comp_db = Component.get_exactly(self.comp.c_id)
        self.assertEqual(self.comp.c_exe, comp_db.c_exe)
Exemplo n.º 6
0
    def test_update(self):
        """ Checks if data can be changed
        """
        self.comp.create_table()
        self.comp.save()
        self.comp.c_exe = "updatedexe"
        self.comp.save()

        # raw database check
        self.cursor.execute("SELECT * FROM Component;")
        result = self.cursor.fetchall()
        self.assertEqual(len(result), 1, "too much or too less objects")
        self.cursor.execute("SELECT * FROM Component;")
        res = self.cursor.fetchone()
        res = tuple(res)
        self.assertEqual(res[3], "updatedexe",
                         "Seems not to be updated correctly")

        # Object oriented check
        comp_db = Component.get_exactly(self.comp.c_id)
        self.assertEqual(self.comp.c_exe, comp_db.c_exe)
Exemplo n.º 7
0
 def test_get_exactly(self):
     self.comp.create_table()
     self.comp.save()
     comp = Component.get_exactly(self.comp.c_id)
     self.assertEqual(comp, self.comp, "Could not deserialize data")
Exemplo n.º 8
0
 def test_get_exactly(self):
     self.comp.create_table()
     self.comp.save()
     comp = Component.get_exactly(self.comp.c_id)
     self.assertEqual(comp, self.comp, "Could not deserialize data")