def setUp(self):
        obj = DummyTutkaQueryObj()
        self.obj = obj
        self.first_query = obj.query
        self.second_query = obj.query2
        self.third_query = obj.query3

        self.recur_test_query = {
            'asdf': ['äöesd', 'AsÄlä'],
            'olololol': {
                'asdfg': 'päsdfö',
                'äes': 'päsähti',
                'däcti': {
                    'testiä': 'testip'
                }
            },
            'testi': 'yeah'
        }

        self.test_result = test_result
        self.test_result2 = test_result2

        self.first_query_key = KeyGenerator(self.first_query).generate()
        self.second_query_key = KeyGenerator(self.second_query).generate()
        self.test_result_key = KeyGenerator(self.test_result).generate()
        self.test_result2_key = KeyGenerator(self.test_result2).generate()
    def test_key_generate_dif(self):
        self.assertNotEquals(self.first_query_key, self.second_query_key,
                             "Different queries will have different keys")
        self.assertNotEquals(self.test_result_key, self.test_result2_key,
                             "Different queries will have different keys")
        #additional test
        obj = DummyTutkaQueryObj()

        key = KeyGenerator(obj.query4).generate()
        key2 = KeyGenerator(obj.query2).generate()
        self.assertNotEquals(key, key2,
                             "Different queries will have different keys")
    def test_keygenerator_final(self):
        key = KeyGenerator(self.obj.query3).generate()
        key2 = KeyGenerator(self.obj.query3).generate()
        key3 = KeyGenerator(self.obj.query3).generate()
        key4 = KeyGenerator(self.obj.query3).generate()

        self.assertEquals(key, key2)
        self.assertEquals(key, key3)
        self.assertEquals(key, key4)
        self.assertEquals(key2, key2)
        self.assertEquals(key2, key3)
        self.assertEquals(key2, key4)
 def test_key_generate_equal(self):
     self.assertTrue(
         KeyGenerator(self.second_query).generate() == KeyGenerator(
             self.second_query).generate(),
         "Similar queries will have similar keys")
     self.assertTrue(
         KeyGenerator(self.third_query).generate() == KeyGenerator(
             self.third_query).generate(),
         "Similar queries will have similar keys ")
     self.assertTrue(
         KeyGenerator(self.first_query).generate() == KeyGenerator(
             self.first_query).generate(),
         "Similar queries will have similar keys")
 def test_key_generate_special(self):
     # Test special characters
     key = KeyGenerator("jyu_30").generate()
     key2 = KeyGenerator("jyu_31").generate()
     self.assertNotEquals(key, key2)
    def test_key_change(self):
        result_key = KeyGenerator(self.recur_test_query).generate()
        self.recur_test_query['asdf']['olololol']['asdfg'] = ['s', 'v', 'k']

        changed_result_key = KeyGenerator(self.recur_test_query).generate()
        self.assertNotEquals(changed_result_key, result_key)
 def test_key_generate_recur(self):
     self.assertTrue(
         type(KeyGenerator(self.recur_test_query).generate()) == type(
             'asd'))