@@ -25,22 +25,25 @@ def test_env(self):
2525 os .environ .get ("LIGHTHOUSE_TOKEN" ), None , "token is not None"
2626 )
2727
28- def test_Upload_file (self ):
28+ def test_upload_file (self ):
2929 """test Upload function"""
3030 l = Lighthouse () # will use env var
3131 res = l .upload ("tests/testdir/testfile.txt" )
3232 self .assertNotEqual (res .get ("data" ), None , "data is None" )
3333 self .assertNotEqual (res .get ("data" ).get ("Hash" ), None , "data is None" )
3434
35- def test_Upload_dir (self ):
35+ def test_upload_dir (self ):
3636 """test Upload function"""
3737 l = Lighthouse (os .environ .get ("LIGHTHOUSE_TOKEN" ))
38- res = l .upload ("tests/testdir/ " )
38+ res = l .upload ("tests/" )
3939 self .assertNotEqual (res .get ("data" ), None , "data is None" )
4040 self .assertIsInstance (res .get ("data" ), dict , "data is a dict" )
41- self .assertNotEqual (res .get ("data" ).get ("Hash" ), None , "data is None" )
41+ self .assertIsInstance (res .get ("data" ).get (
42+ "Hash" ), str , "Instance is not of type String" )
43+ self .assertIsInstance (res .get ("data" ).get (
44+ "Size" ), str , "Instance is not of type String" )
4245
43- def test_Upload_Blob (self ):
46+ def test_upload_Blob (self ):
4447 """test Upload function"""
4548 l = Lighthouse (os .environ .get ("LIGHTHOUSE_TOKEN" ))
4649 res = l .uploadBlob (
@@ -49,7 +52,7 @@ def test_Upload_Blob(self):
4952 self .assertIsInstance (res .get ("data" ), dict , "data is a dict" )
5053 self .assertNotEqual (res .get ("data" ).get ("Hash" ), None , "data is None" )
5154
52- def test_Upload_File (self ):
55+ def test_upload_File (self ):
5356 """test Upload function"""
5457 l = Lighthouse (os .environ .get ("LIGHTHOUSE_TOKEN" ))
5558 with open ("./.gitignore" , "rb" ) as file :
@@ -59,6 +62,30 @@ def test_Upload_File(self):
5962 self .assertNotEqual (res .get ("data" ).get (
6063 "Hash" ), None , "data is None" )
6164
65+ def test_upload_with_tag (self ):
66+ """test Upload with tag function"""
67+ l = Lighthouse (os .environ .get ("LIGHTHOUSE_TOKEN" ))
68+ tag = generate_random_string (8 )
69+ res = l .uploadBlob (
70+ io .BytesIO (b"tests/testdir/" + generate_random_string (80 ).encode ("utf-8" )), f"{ generate_random_string (16 )} .txt" , tag )
71+ self .assertNotEqual (res .get ("data" ), None , "data is None" )
72+ self .assertIsInstance (res .get ("data" ), dict , "data is a dict" )
73+ self .assertIsInstance (res .get ("data" ).get (
74+ "Hash" ), str , "Hash is not of type string" )
75+
76+ tagData = l .getTagged (tag )
77+ self .assertEqual (tag , tagData .get ("data" ).get ("tag" ), "Tag dont match" )
78+ self .assertEqual (res .get ("data" ).get ("Hash" ), tagData .get (
79+ "data" ).get ("cid" ), "Tag dont match" )
80+
81+ # overWrite tag
82+ res = l .uploadBlob (
83+ io .BytesIO (b"tests/testdir/" + generate_random_string (80 ).encode ("utf-8" )), f"{ generate_random_string (16 )} .txt" , tag )
84+ tagData = l .getTagged (tag )
85+ self .assertEqual (tag , tagData .get ("data" ).get ("tag" ), "Tag dont match" )
86+ self .assertEqual (res .get ("data" ).get ("Hash" ), tagData .get (
87+ "data" ).get ("cid" ), "Tag dont match" )
88+
6289
6390if __name__ == "__main__" :
6491 unittest .main ()
0 commit comments