<s> from __future__ import ( absolute_import , division , generators , nested_scopes , print_function , <EOL> unicode_literals , with_statement ) <EOL> import unittest <EOL> from pants . backend . jvm . jar_dependency_utils import M2Coordinate , ResolvedJar <EOL> class JarDependencyUtilsTest ( unittest . TestCase ) : <EOL> def test_m2_string_representation ( self ) : <EOL> org_name_ref = M2Coordinate ( org = '<STR_LIT>' , name = '<STR_LIT>' , rev = '<STR_LIT>' ) <EOL> self . assertEquals ( '<STR_LIT>' , str ( org_name_ref ) ) <EOL> self . assertEquals ( org_name_ref , M2Coordinate . from_string ( str ( org_name_ref ) ) ) <EOL> org_name_ref_classifier = M2Coordinate ( org = '<STR_LIT>' , name = '<STR_LIT>' , <EOL> rev = '<STR_LIT>' , classifier = '<STR_LIT>' ) <EOL> self . assertEquals ( '<STR_LIT>' , str ( org_name_ref_classifier ) ) <EOL> self . assertEquals ( org_name_ref_classifier , M2Coordinate . from_string ( str ( org_name_ref_classifier ) ) ) <EOL> org_name_classifier = M2Coordinate ( org = '<STR_LIT>' , name = '<STR_LIT>' , classifier = '<STR_LIT>' ) <EOL> self . assertEquals ( '<STR_LIT>' , str ( org_name_classifier ) ) <EOL> self . assertEquals ( org_name_classifier , M2Coordinate . from_string ( str ( org_name_classifier ) ) ) <EOL> org_name_type_classifier = M2Coordinate ( org = '<STR_LIT>' , name = '<STR_LIT>' , <EOL> classifier = '<STR_LIT>' , ext = '<STR_LIT>' ) <EOL> self . assertEquals ( '<STR_LIT>' , str ( org_name_type_classifier ) ) <EOL> self . assertEquals ( org_name_type_classifier , M2Coordinate . from_string ( str ( org_name_type_classifier ) ) ) <EOL> org_name_type_jar_classifier = M2Coordinate ( org = '<STR_LIT>' , name = '<STR_LIT>' , <EOL> classifier = '<STR_LIT>' , ext = '<STR_LIT>' ) <EOL> self . assertEquals ( '<STR_LIT>' , str ( org_name_type_jar_classifier ) ) <EOL> self . assertEquals ( org_name_type_jar_classifier , M2Coordinate . from_string ( str ( org_name_type_jar_classifier ) ) ) <EOL> def test_m2_coordinates_with_same_properties ( self ) : <EOL> coordinate1 = M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> coordinate2 = M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( coordinate1 , coordinate2 ) <EOL> self . assertEqual ( hash ( coordinate1 ) , hash ( coordinate2 ) ) <EOL> def test_m2_coordinates_with_differing_properties_not_equal ( self ) : <EOL> coordinate1 = M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> coordinate2 = M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertNotEqual ( coordinate1 , coordinate2 ) <EOL> def test_m2_coordinates_with_different_types_have_different_hashes ( self ) : <EOL> coordinate1 = M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' , ext = '<STR_LIT>' ) <EOL> coordinate2 = M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertNotEqual ( hash ( coordinate1 ) , hash ( coordinate2 ) ) <EOL> def test_m2_coordinate_artifact_path_no_rev ( self ) : <EOL> coordinate = M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , coordinate . artifact_filename ) <EOL> def test_m2_coordinate_artifact_path_no_classifier ( self ) : <EOL> coordinate = M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , coordinate . artifact_filename ) <EOL> def test_m2_coordinate_artifact_path_classifier ( self ) : <EOL> coordinate = M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , coordinate . artifact_filename ) <EOL> def test_m2_coordinate_artifact_path_explicit_ext ( self ) : <EOL> coordinate = M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ext = '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , coordinate . artifact_filename ) <EOL> def test_resolved_jars_with_same_properties ( self ) : <EOL> jar1 = ResolvedJar ( M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT:path>' ) <EOL> jar2 = ResolvedJar ( M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT:path>' ) <EOL> self . assertEqual ( jar1 , jar2 ) <EOL> self . assertEqual ( hash ( jar1 ) , hash ( jar2 ) ) <EOL> def test_resolved_jars_with_differing_cache_paths_not_equal ( self ) : <EOL> jar1 = ResolvedJar ( M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> jar2 = ResolvedJar ( M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertNotEqual ( jar1 , jar2 ) <EOL> def test_resolved_jars_with_differing_paths_not_equal ( self ) : <EOL> jar1 = ResolvedJar ( M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> jar2 = ResolvedJar ( M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertNotEqual ( jar1 , jar2 ) <EOL> def test_resolved_jars_with_same_paths_equal ( self ) : <EOL> jar1 = ResolvedJar ( M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT:path>' ) <EOL> jar2 = ResolvedJar ( M2Coordinate ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT:path>' ) <EOL> self . assertEqual ( jar1 , jar2 ) <EOL> def test_m2_coordinate_create_noop ( self ) : <EOL> m2 = M2Coordinate ( org = '<STR_LIT:a>' , name = '<STR_LIT:b>' , rev = '<STR_LIT:c>' , classifier = '<STR_LIT:d>' , ext = '<STR_LIT:e>' ) <EOL> m2_new = M2Coordinate . create ( m2 ) <EOL> self . assertIs ( m2 , m2_new ) <EOL> def test_m2_coordinate_create ( self ) : <EOL> attrs = ( '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class CoordinateLike ( object ) : <EOL> def __init__ ( self ) : <EOL> for i , a in enumerate ( attrs ) : <EOL> setattr ( self , a , chr ( i + ord ( '<STR_LIT:a>' ) ) ) <EOL> coord = CoordinateLike ( ) <EOL> m2 = M2Coordinate . create ( coord ) <EOL> self . assertNotEqual ( m2 , coord ) <EOL> self . assertEquals ( tuple ( getattr ( coord , a ) for a in attrs ) , <EOL> tuple ( getattr ( m2 , a ) for a in attrs ) ) <EOL> def test_m2_coordinate_unversioned_noop ( self ) : <EOL> m2 = M2Coordinate ( org = '<STR_LIT:a>' , name = '<STR_LIT:b>' , rev = None , classifier = '<STR_LIT:d>' , ext = '<STR_LIT:e>' ) <EOL> m2_un = M2Coordinate . unversioned ( m2 ) <EOL> self . assertIs ( m2 , m2_un ) <EOL> def test_m2_coordinate_unversioned ( self ) : <EOL> m2 = M2Coordinate ( org = '<STR_LIT:a>' , name = '<STR_LIT:b>' , rev = '<STR_LIT:c>' , classifier = '<STR_LIT:d>' , ext = '<STR_LIT:e>' ) <EOL> m2_un = M2Coordinate . unversioned ( m2 ) <EOL> self . assertNotEquals ( m2 , m2_un ) <EOL> self . assertTrue ( m2_un . rev is None ) </s>
