Beispiel #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"))
Beispiel #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"))
Beispiel #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"]))
Beispiel #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"]))
Beispiel #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"))
Beispiel #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"]))
Beispiel #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"]))
Beispiel #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"))
Beispiel #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"]))
Beispiel #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"]))
Beispiel #11
0
 def test_query_existing_tag_with_no_results(self):
     self.assertListEqual([],
                          lasertag.query(["source:http", "host:bank.com"]))
Beispiel #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)
Beispiel #13
0
 def test_query_invalid_tag(self):
     self.assertListEqual([], lasertag.query(["invalid"]))
Beispiel #14
0
 def test_query_multiple_tags_with_multiple_matching_values(self):
     self.assertListEqual(["desc1", "image2.jpg"],
                          lasertag.query(["source:http", "userid:345"]))
Beispiel #15
0
 def test_query_single_tag_with_multiple_matching_values(self):
     self.assertListEqual(["image1.jpg", "image2.jpg", "image3.jpg"],
                          lasertag.query(["type:image"]))
Beispiel #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)
Beispiel #17
0
 def test_empty_query(self):
     with self.assertRaises(AttributeError):
         lasertag.query([])
Beispiel #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"]))
Beispiel #19
0
 def test_query_single_tag_with_single_matching_value(self):
     self.assertListEqual(["bank-thing1"],
                          lasertag.query(["host:bank.com"]))
Beispiel #20
0
 def test_query_existing_tag_with_no_results(self):
     self.assertListEqual([],
                          lasertag.query(["source:http", "host:bank.com"]))
Beispiel #21
0
 def test_query_invalid_tag(self):
     self.assertListEqual([], lasertag.query(["invalid"]))
Beispiel #22
0
 def test_query_single_tag_given_as_string(self):
     self.assertListEqual(["desc1", "image2.jpg"],
                          lasertag.query("userid:345"))
Beispiel #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"]))
Beispiel #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)
Beispiel #25
0
 def test_query_single_tag_given_as_string(self):
     self.assertListEqual(["desc1", "image2.jpg"],
                          lasertag.query("userid:345"))
Beispiel #26
0
 def test_query_single_tag_with_single_matching_value(self):
     self.assertListEqual(["bank-thing1"],
                          lasertag.query(["host:bank.com"]))
Beispiel #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)
Beispiel #28
0
 def test_query_single_tag_with_multiple_matching_values(self):
     self.assertListEqual(["image1.jpg", "image2.jpg", "image3.jpg"],
                          lasertag.query(["type:image"]))
Beispiel #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)
Beispiel #30
0
 def test_query_multiple_tags_with_single_matching_value(self):
     self.assertListEqual(["bank-thing1"],
                          lasertag.query(["host:bank.com", "source:sftp"]))
Beispiel #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"]))
Beispiel #32
0
 def test_query_multiple_tags_with_multiple_matching_values(self):
     self.assertListEqual(["desc1", "image2.jpg"],
                          lasertag.query(["source:http", "userid:345"]))
Beispiel #33
0
 def test_query_multiple_tags_with_single_matching_value(self):
     self.assertListEqual(["bank-thing1"],
                          lasertag.query(["host:bank.com", "source:sftp"]))
Beispiel #34
0
 def test_empty_query(self):
     with self.assertRaises(AttributeError):
         lasertag.query([])
Beispiel #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"]))
Beispiel #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)