From 175c7dc9eddf9e183c8a3e62c2f64895333fd5a3 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Mon, 9 Dec 2024 17:16:13 +0100 Subject: [PATCH] References should manage imports and imports with aliases --- .../FamixPythonProject1Test.class.st | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st b/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st index 1e1fd0d..1664494 100644 --- a/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st +++ b/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st @@ -2338,6 +2338,53 @@ FamixPythonProject1Test >> testReferenceFromPackage [ self assert: (package outgoingReferences anySatisfy: [ :aReference | aReference referredType = class ]) ] +{ #category : 'tests - references' } +FamixPythonProject1Test >> testReferenceOfImportedEntity [ + + | class module reference | + class := self classNamed: 'Person'. + module := self moduleNamed: 'moduleAtRoot5'. + + reference := class incomingReferences detect: [ :aReference | aReference referencer = module ]. + + self assert: reference class equals: FamixPythonReference. + self assert: reference source equals: module. + self assert: reference referencer equals: module. + self assert: reference target equals: class. + self assert: reference referredType equals: class. + self assert: (module outgoingReferences anySatisfy: [ :aReference | aReference referredType = class ]) +] + +{ #category : 'tests - references' } +FamixPythonProject1Test >> testReferenceOfImportedEntityViaAlias [ + + | class module reference | + class := self classNamed: 'Employee'. + module := self moduleNamed: 'moduleWithImportsAndAliases'. + + reference := class incomingReferences detect: [ :aReference | aReference referencer = module ]. + + self assert: reference class equals: FamixPythonReference. + self assert: reference source equals: module. + self assert: reference referencer equals: module. + self assert: reference target equals: class. + self assert: reference referredType equals: class. + self assert: (module outgoingReferences anySatisfy: [ :aReference | aReference referredType = class ]). +] + +{ #category : 'tests - references' } +FamixPythonProject1Test >> testReferenceOfImportedEntityViaAliasSourceAnchor [ + + | class module reference | + class := self classNamed: 'Employee'. + module := self moduleNamed: 'moduleWithImportsAndAliases'. + + reference := class incomingReferences detect: [ :aReference | aReference referencer = module ]. + + self assert: reference sourceAnchor isNotNil. + self assert: reference sourceText equals: 'Emp' +] + { #category : 'tests - references' } FamixPythonProject1Test >> testReferenceSourceAnchor [