11"""
2- SPDX-License-Identifier: MIT
2+ SPDX-License-Identifier: MIT
33
4- Copyright (c) 2021, SCANOSS
4+ Copyright (c) 2021, SCANOSS
55
6- Permission is hereby granted, free of charge, to any person obtaining a copy
7- of this software and associated documentation files (the "Software"), to deal
8- in the Software without restriction, including without limitation the rights
9- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10- copies of the Software, and to permit persons to whom the Software is
11- furnished to do so, subject to the following conditions:
6+ Permission is hereby granted, free of charge, to any person obtaining a copy
7+ of this software and associated documentation files (the "Software"), to deal
8+ in the Software without restriction, including without limitation the rights
9+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ copies of the Software, and to permit persons to whom the Software is
11+ furnished to do so, subject to the following conditions:
1212
13- The above copyright notice and this permission notice shall be included in
14- all copies or substantial portions of the Software.
13+ The above copyright notice and this permission notice shall be included in
14+ all copies or substantial portions of the Software.
1515
16- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22- THE SOFTWARE.
16+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+ THE SOFTWARE.
2323"""
24+
2425import os
2526import unittest
2627
@@ -32,17 +33,18 @@ class MyTestCase(unittest.TestCase):
3233 """
3334 Unit test cases for GRPC comms
3435 """
35- TEST_LOCAL = os .getenv ("SCANOSS_TEST_LOCAL" , 'True' ).lower () in ('true' , '1' , 't' , 'yes' , 'y' )
36+
37+ TEST_LOCAL = os .getenv ('SCANOSS_TEST_LOCAL' , 'True' ).lower () in ('true' , '1' , 't' , 'yes' , 'y' )
3638
3739 def test_grpc_dep_echo (self ):
3840 """
3941 Test the basic echo rpc call on the local server
4042 """
4143 if MyTestCase .TEST_LOCAL :
42- server_type = " local"
44+ server_type = ' local'
4345 grpc_client = ScanossGrpc (debug = True , url = 'localhost:50051' )
4446 else :
45- server_type = " remote"
47+ server_type = ' remote'
4648 grpc_client = ScanossGrpc (debug = True )
4749 echo_resp = grpc_client .deps_echo (f'testing dep echo ({ server_type } )' )
4850 print (f'Echo Resp ({ server_type } ): { echo_resp } ' )
@@ -53,23 +55,26 @@ def test_grpc_get_dependencies(self):
5355 Test getting dependencies from the local gRPC server
5456 """
5557 sc_deps = ScancodeDeps (debug = True )
56- dep_file = " data/scancode-deps.json"
58+ dep_file = ' data/scancode-deps.json'
5759 deps = sc_deps .produce_from_file (dep_file )
5860 print (f'Dependency JSON: { deps } ' )
5961 self .assertIsNotNone (deps )
6062 if MyTestCase .TEST_LOCAL :
61- server_type = " local"
63+ server_type = ' local'
6264 grpc_client = ScanossGrpc (debug = True , url = 'localhost:50051' )
6365 else :
64- server_type = " remote"
66+ server_type = ' remote'
6567 grpc_client = ScanossGrpc (debug = True )
6668 resp = grpc_client .get_dependencies (deps )
6769 print (f'Resp ({ server_type } ): { resp } ' )
6870 self .assertIsNotNone (resp )
6971
70- dep_files = resp .get (" files" )
72+ dep_files = resp .get (' files' )
7173 if dep_files and len (dep_files ) > 0 :
7274 for dep_file in dep_files :
73- file = dep_file .pop (" file" , None )
75+ file = dep_file .pop (' file' , None )
7476 print (f'File: { file } - { dep_file } ' )
7577
78+
79+ if __name__ == '__main__' :
80+ unittest .main ()
0 commit comments