1- import pytest
1+ import unittest
22from entrypoint .data_model import ArtifactType , ScanConfig
33
44
@@ -7,87 +7,83 @@ class MockArgs:
77 artifact_path = './test'
88
99
10- def test_artifact_type_repository_exists ():
11- assert ArtifactType .REPOSITORY .value == "repository"
10+ class TestDataModel (unittest .TestCase ):
1211
13- def test_artifact_type_container_exists ( ):
14- assert ArtifactType .CONTAINER .value == "container"
12+ def test_artifact_type_repository_exists ( self ):
13+ self . assertEqual ( ArtifactType .REPOSITORY .value , "repository" )
1514
16- def test_artifact_type_binary_exists ( ):
17- assert ArtifactType .BINARY .value == "binary"
15+ def test_artifact_type_container_exists ( self ):
16+ self . assertEqual ( ArtifactType .CONTAINER .value , "container" )
1817
19- def test_artifact_type_archive_exists ( ):
20- assert ArtifactType .ARCHIVE .value == "archive"
18+ def test_artifact_type_binary_exists ( self ):
19+ self . assertEqual ( ArtifactType .BINARY .value , "binary" )
2120
22- def test_artifact_type_from_string ( ):
23- assert ArtifactType ( "repository" ) == ArtifactType .REPOSITORY
21+ def test_artifact_type_archive_exists ( self ):
22+ self . assertEqual ( ArtifactType .ARCHIVE . value , "archive" )
2423
25- def test_artifact_type_invalid_string_raises_exception ():
26- try :
27- ArtifactType ("invalid" )
28- assert False , "Expected ValueError but none was raised"
29- except ValueError :
30- assert True
24+ def test_artifact_type_from_string (self ):
25+ self .assertEqual (ArtifactType ("repository" ), ArtifactType .REPOSITORY )
3126
32- def test_artifact_type_empty_string_raises_exception ():
33- try :
34- ArtifactType ("" )
35- assert False , "Expected ValueError but none was raised"
36- except ValueError :
37- assert True
27+ def test_artifact_type_invalid_string_raises_exception (self ):
28+ with self .assertRaises (ValueError ):
29+ ArtifactType ("invalid" )
3830
39- def test_scan_config_can_be_created ( ):
40- config = ScanConfig ()
41- assert config is not None
31+ def test_artifact_type_empty_string_raises_exception ( self ):
32+ with self . assertRaises ( ValueError ):
33+ ArtifactType ( "" )
4234
43- def test_scan_config_has_artifact_type ( ):
44- config = ScanConfig (artifact_type = ArtifactType . REPOSITORY )
45- assert config . artifact_type == ArtifactType . REPOSITORY
35+ def test_scan_config_can_be_created ( self ):
36+ config = ScanConfig ()
37+ self . assertIsNotNone ( config )
4638
47- def test_scan_config_has_artifact_path ( ):
48- config = ScanConfig (artifact_path = "./test" )
49- assert config .artifact_path == "./test"
39+ def test_scan_config_has_artifact_type ( self ):
40+ config = ScanConfig (artifact_type = ArtifactType . REPOSITORY )
41+ self . assertEqual ( config .artifact_type , ArtifactType . REPOSITORY )
5042
51- def test_scan_config_from_args_exists ():
52- mock_args = MockArgs ()
53- config = ScanConfig .from_args (mock_args )
54- assert config is not None
43+ def test_scan_config_has_artifact_path (self ):
44+ config = ScanConfig (artifact_path = "./test" )
45+ self .assertEqual (config .artifact_path , "./test" )
5546
56- def test_scan_config_from_args_converts_artifact_type ( ):
57- mock_args = MockArgs ()
58- config = ScanConfig .from_args (mock_args )
59- assert config . artifact_type == ArtifactType . REPOSITORY
47+ def test_scan_config_from_args_exists ( self ):
48+ mock_args = MockArgs ()
49+ config = ScanConfig .from_args (mock_args )
50+ self . assertIsNotNone ( config )
6051
61- def test_scan_config_from_args_converts_artifact_path ( ):
62- mock_args = MockArgs ()
63- config = ScanConfig .from_args (mock_args )
64- assert config .artifact_path == './test'
52+ def test_scan_config_from_args_converts_artifact_type ( self ):
53+ mock_args = MockArgs ()
54+ config = ScanConfig .from_args (mock_args )
55+ self . assertEqual ( config .artifact_type , ArtifactType . REPOSITORY )
6556
66- def test_scan_config_repository_type_comparison ():
67- config = ScanConfig (artifact_type = ArtifactType .REPOSITORY )
68- assert config .artifact_type == ArtifactType .REPOSITORY
57+ def test_scan_config_from_args_converts_artifact_path (self ):
58+ mock_args = MockArgs ()
59+ config = ScanConfig .from_args (mock_args )
60+ self .assertEqual (config .artifact_path , './test' )
6961
70- def test_scan_config_container_type_comparison ( ):
71- config = ScanConfig (artifact_type = ArtifactType .CONTAINER )
72- assert config .artifact_type == ArtifactType .CONTAINER
62+ def test_scan_config_repository_type_comparison ( self ):
63+ config = ScanConfig (artifact_type = ArtifactType .REPOSITORY )
64+ self . assertEqual ( config .artifact_type , ArtifactType .REPOSITORY )
7365
74- def test_scan_config_binary_type_comparison ( ):
75- config = ScanConfig (artifact_type = ArtifactType .BINARY )
76- assert config .artifact_type == ArtifactType .BINARY
66+ def test_scan_config_container_type_comparison ( self ):
67+ config = ScanConfig (artifact_type = ArtifactType .CONTAINER )
68+ self . assertEqual ( config .artifact_type , ArtifactType .CONTAINER )
7769
78- def test_scan_config_archive_type_comparison ( ):
79- config = ScanConfig (artifact_type = ArtifactType .ARCHIVE )
80- assert config .artifact_type == ArtifactType .ARCHIVE
70+ def test_scan_config_binary_type_comparison ( self ):
71+ config = ScanConfig (artifact_type = ArtifactType .BINARY )
72+ self . assertEqual ( config .artifact_type , ArtifactType .BINARY )
8173
82- def test_scan_config_container_platform_check ( ):
83- config = ScanConfig (artifact_type = ArtifactType .CONTAINER )
84- assert config .artifact_type == ArtifactType .CONTAINER
74+ def test_scan_config_archive_type_comparison ( self ):
75+ config = ScanConfig (artifact_type = ArtifactType .ARCHIVE )
76+ self . assertEqual ( config .artifact_type , ArtifactType .ARCHIVE )
8577
86- def test_scan_config_artifact_type_value ( ):
87- config = ScanConfig (artifact_type = ArtifactType .REPOSITORY )
88- assert config .artifact_type . value == "repository"
78+ def test_scan_config_container_platform_check ( self ):
79+ config = ScanConfig (artifact_type = ArtifactType .CONTAINER )
80+ self . assertEqual ( config .artifact_type , ArtifactType . CONTAINER )
8981
90- def test_scan_config_display_mapping ():
91- config = ScanConfig (artifact_type = ArtifactType .REPOSITORY )
92- display_type = "repository" if config .artifact_type == ArtifactType .REPOSITORY else config .artifact_type .value
93- assert display_type == "repository"
82+ def test_scan_config_artifact_type_value (self ):
83+ config = ScanConfig (artifact_type = ArtifactType .REPOSITORY )
84+ self .assertEqual (config .artifact_type .value , "repository" )
85+
86+ def test_scan_config_display_mapping (self ):
87+ config = ScanConfig (artifact_type = ArtifactType .REPOSITORY )
88+ display_type = "repository" if config .artifact_type == ArtifactType .REPOSITORY else config .artifact_type .value
89+ self .assertEqual (display_type , "repository" )
0 commit comments