Ejemplo n.º 1
0
 def test_add_duplicate_rollsback_changes(self):
     lasertag.add_value(["a", "b", "c"], "v")
     with self.assertRaises(AttributeError):
         lasertag.add_value(["c", "d", "e", "f"], "v")
     self.assertEqual([], lasertag.query("d"))
     self.assertEqual([], lasertag.query("e"))
     self.assertEqual([], lasertag.query("f"))
Ejemplo n.º 2
0
 def test_add_duplicate_rollsback_changes(self):
     lasertag.add_value(["a", "b", "c"], "v")
     with self.assertRaises(AttributeError):
         lasertag.add_value(["c", "d", "e", "f"], "v")
     self.assertEqual([], lasertag.query("d"))
     self.assertEqual([], lasertag.query("e"))
     self.assertEqual([], lasertag.query("f"))
Ejemplo n.º 3
0
    def test_add_with_value_transformer(self):
        lasertag.add_value(["t1", "t2"], "value",
                           transformers=[self.TestValueTransfomer()])

        self.assertEqual([], lasertag.query("new"))
        self.assertEqual([], lasertag.query("tags"))
        self.assertEqual(["new value"], lasertag.query(["t1", "t2"]))
Ejemplo n.º 4
0
    def test_add_with_value_transformer(self):
        lasertag.add_value(["t1", "t2"],
                           "value",
                           transformers=[self.TestValueTransfomer()])

        self.assertEqual([], lasertag.query("new"))
        self.assertEqual([], lasertag.query("tags"))
        self.assertEqual(["new value"], lasertag.query(["t1", "t2"]))
Ejemplo n.º 5
0
 def test_rename_with_value(self):
     lasertag.rename_tag("userid:345", "userid:999", with_value="image2.jpg")
     self.assertTrue(len(lasertag.query("userid:345")) == 1)
     self.assertTrue(len(lasertag.query("userid:999")) == 1)
     self.assertEqual(["source:http", "userid:345", "type:description"],
                      lasertag.tags("desc1"))
     self.assertEqual(["source:http", "userid:999", "type:image"],
                      lasertag.tags("image2.jpg"))
Ejemplo n.º 6
0
    def test_add_with_both_tag_and_value_transformer(self):
        lasertag.add_value(["t1", "t2"], "value",
                           transformers=[self.TestTransfomer()])

        self.assertEqual([], lasertag.query("t1"))
        self.assertEqual([], lasertag.query("t2"))
        self.assertEqual([], lasertag.tags("value"))
        self.assertEqual(["new value"], lasertag.query(["new", "tags"]))
Ejemplo n.º 7
0
    def test_add_with_both_tag_and_value_transformer(self):
        lasertag.add_value(["t1", "t2"],
                           "value",
                           transformers=[self.TestTransfomer()])

        self.assertEqual([], lasertag.query("t1"))
        self.assertEqual([], lasertag.query("t2"))
        self.assertEqual([], lasertag.tags("value"))
        self.assertEqual(["new value"], lasertag.query(["new", "tags"]))
Ejemplo n.º 8
0
 def test_rename_with_value(self):
     lasertag.rename_tag("userid:345",
                         "userid:999",
                         with_value="image2.jpg")
     self.assertTrue(len(lasertag.query("userid:345")) == 1)
     self.assertTrue(len(lasertag.query("userid:999")) == 1)
     self.assertEqual(["source:http", "userid:345", "type:description"],
                      lasertag.tags("desc1"))
     self.assertEqual(["source:http", "userid:999", "type:image"],
                      lasertag.tags("image2.jpg"))
Ejemplo n.º 9
0
    def test_add_with_multiple_transfomers(self):
        lasertag.add_value(["t1", "t2"], "value",
                           transformers=[
                               self.TestTagTransformer(),
                               self.TestValueTransfomer()
                           ])

        self.assertEqual([], lasertag.query("t1"))
        self.assertEqual([], lasertag.query("t2"))
        self.assertEqual([], lasertag.tags("value"))
        self.assertEqual(["new value"], lasertag.query(["new", "tags"]))
Ejemplo n.º 10
0
    def test_add_with_multiple_transfomers(self):
        lasertag.add_value(["t1", "t2"],
                           "value",
                           transformers=[
                               self.TestTagTransformer(),
                               self.TestValueTransfomer()
                           ])

        self.assertEqual([], lasertag.query("t1"))
        self.assertEqual([], lasertag.query("t2"))
        self.assertEqual([], lasertag.tags("value"))
        self.assertEqual(["new value"], lasertag.query(["new", "tags"]))
Ejemplo n.º 11
0
 def test_query_existing_tag_with_no_results(self):
     self.assertListEqual([],
                          lasertag.query(["source:http", "host:bank.com"]))
Ejemplo n.º 12
0
 def test_rename_no_occurrence_tag(self):
     lasertag.rename_tag("invalid", to="invalid2")
     self.assertTrue(len(lasertag.query("invalid")) == 0)
     self.assertTrue(len(lasertag.query("invalid2")) == 0)
Ejemplo n.º 13
0
 def test_query_invalid_tag(self):
     self.assertListEqual([], lasertag.query(["invalid"]))
Ejemplo n.º 14
0
 def test_query_multiple_tags_with_multiple_matching_values(self):
     self.assertListEqual(["desc1", "image2.jpg"],
                          lasertag.query(["source:http", "userid:345"]))
Ejemplo n.º 15
0
 def test_query_single_tag_with_multiple_matching_values(self):
     self.assertListEqual(["image1.jpg", "image2.jpg", "image3.jpg"],
                          lasertag.query(["type:image"]))
Ejemplo n.º 16
0
 def test_rename_multi_occurrence_tag(self):
     lasertag.rename_tag("userid:345", to="userid:999")
     self.assertTrue(len(lasertag.query("userid:345")) == 0)
     self.assertTrue(len(lasertag.query("userid:999")) == 2)
Ejemplo n.º 17
0
 def test_empty_query(self):
     with self.assertRaises(AttributeError):
         lasertag.query([])
Ejemplo n.º 18
0
 def test_add_empty_transformer_list(self):
     lasertag.add_value(["t1", "t2"], "hello world", transformers=[])
     self.assertTrue("hello world" in lasertag.query(["t1"]))
     self.assertTrue("hello world" in lasertag.query(["t2"]))
     self.assertTrue("hello world" in lasertag.query(["t1", "t2"]))
Ejemplo n.º 19
0
 def test_query_single_tag_with_single_matching_value(self):
     self.assertListEqual(["bank-thing1"],
                          lasertag.query(["host:bank.com"]))
Ejemplo n.º 20
0
 def test_query_existing_tag_with_no_results(self):
     self.assertListEqual([],
                          lasertag.query(["source:http", "host:bank.com"]))
Ejemplo n.º 21
0
 def test_query_invalid_tag(self):
     self.assertListEqual([], lasertag.query(["invalid"]))
Ejemplo n.º 22
0
 def test_query_single_tag_given_as_string(self):
     self.assertListEqual(["desc1", "image2.jpg"],
                          lasertag.query("userid:345"))
Ejemplo n.º 23
0
 def test_individual_tags_are_added(self):
     lasertag.add_value(["t1", "t2"], "hello world")
     self.assertTrue("hello world" in lasertag.query(["t1"]))
     self.assertTrue("hello world" in lasertag.query(["t2"]))
     self.assertTrue("hello world" in lasertag.query(["t1", "t2"]))
Ejemplo n.º 24
0
 def test_rename_single_occurrence_tag(self):
     lasertag.rename_tag("host:bank.com", to="host:anotherbank.com")
     self.assertTrue(len(lasertag.query("host:bank.com")) == 0)
     self.assertTrue(len(lasertag.query("host:anotherbank.com")) == 1)
Ejemplo n.º 25
0
 def test_query_single_tag_given_as_string(self):
     self.assertListEqual(["desc1", "image2.jpg"],
                          lasertag.query("userid:345"))
Ejemplo n.º 26
0
 def test_query_single_tag_with_single_matching_value(self):
     self.assertListEqual(["bank-thing1"],
                          lasertag.query(["host:bank.com"]))
Ejemplo n.º 27
0
 def test_rename_single_occurrence_tag(self):
     lasertag.rename_tag("host:bank.com", to="host:anotherbank.com")
     self.assertTrue(len(lasertag.query("host:bank.com")) == 0)
     self.assertTrue(len(lasertag.query("host:anotherbank.com")) == 1)
Ejemplo n.º 28
0
 def test_query_single_tag_with_multiple_matching_values(self):
     self.assertListEqual(["image1.jpg", "image2.jpg", "image3.jpg"],
                          lasertag.query(["type:image"]))
Ejemplo n.º 29
0
 def test_rename_no_occurrence_tag(self):
     lasertag.rename_tag("invalid", to="invalid2")
     self.assertTrue(len(lasertag.query("invalid")) == 0)
     self.assertTrue(len(lasertag.query("invalid2")) == 0)
Ejemplo n.º 30
0
 def test_query_multiple_tags_with_single_matching_value(self):
     self.assertListEqual(["bank-thing1"],
                          lasertag.query(["host:bank.com", "source:sftp"]))
Ejemplo n.º 31
0
 def test_individual_tags_are_added(self):
     lasertag.add_value(["t1", "t2"], "hello world")
     self.assertTrue("hello world" in lasertag.query(["t1"]))
     self.assertTrue("hello world" in lasertag.query(["t2"]))
     self.assertTrue("hello world" in lasertag.query(["t1", "t2"]))
Ejemplo n.º 32
0
 def test_query_multiple_tags_with_multiple_matching_values(self):
     self.assertListEqual(["desc1", "image2.jpg"],
                          lasertag.query(["source:http", "userid:345"]))
Ejemplo n.º 33
0
 def test_query_multiple_tags_with_single_matching_value(self):
     self.assertListEqual(["bank-thing1"],
                          lasertag.query(["host:bank.com", "source:sftp"]))
Ejemplo n.º 34
0
 def test_empty_query(self):
     with self.assertRaises(AttributeError):
         lasertag.query([])
Ejemplo n.º 35
0
 def test_add_empty_transformer_list(self):
     lasertag.add_value(["t1", "t2"], "hello world", transformers=[])
     self.assertTrue("hello world" in lasertag.query(["t1"]))
     self.assertTrue("hello world" in lasertag.query(["t2"]))
     self.assertTrue("hello world" in lasertag.query(["t1", "t2"]))
Ejemplo n.º 36
0
 def test_rename_multi_occurrence_tag(self):
     lasertag.rename_tag("userid:345", to="userid:999")
     self.assertTrue(len(lasertag.query("userid:345")) == 0)
     self.assertTrue(len(lasertag.query("userid:999")) == 2)