Skip to content

Commit

Permalink
Add tests for from-import in a package
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Sep 26, 2024
1 parent d665779 commit 20fd303
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,84 @@ FamixPythonProject1Test >> testModuleInSubPackage [
self assert: module parentPackage equals: (self packageNamed: 'subpackage1')
]

{ #category : 'tests - from-import' }
FamixPythonProject1Test >> testPackageImportsClassFromAModule [

| package class import |
self denyEmpty: self model allImports.
package := self packageNamed: 'subpackageInRoot2'.
class := self classNamed: 'Person'.
import := package outgoingImports detect: [ :pimport | pimport target name = 'Person' ].

self assert: import importingEntity equals: package.
self assert: import importedEntity equals: class
]

{ #category : 'tests - from-import' }
FamixPythonProject1Test >> testPackageImportsClassFromAPackage [

| package class import |
self denyEmpty: self model allImports.
package := self packageNamed: 'subpackageInRoot2'.
class := self classNamed: 'Room'.
import := package outgoingImports detect: [ :pimport | pimport target name = 'Room' ].

self assert: import importingEntity equals: package.
self assert: import importedEntity equals: class
]

{ #category : 'tests - from-import' }
FamixPythonProject1Test >> testPackageImportsFunctionFromAModule [

| package function import |
self denyEmpty: self model allImports.
package := self packageNamed: 'subpackageInRoot2'.
function := self functionNamed: 'sort_list'.
import := package outgoingImports detect: [ :pimport | pimport target name = 'sort_list' ].

self assert: import importingEntity equals: package.
self assert: import importedEntity equals: function
]

{ #category : 'tests - from-import' }
FamixPythonProject1Test >> testPackageImportsFunctionFromAPackage [

| package function import |
self denyEmpty: self model allImports.
package := self packageNamed: 'subpackageInRoot2'.
function := self functionNamed: 'return2'.
import := package outgoingImports detect: [ :pimport | pimport target name = 'return2' ].

self assert: import importingEntity equals: package.
self assert: import importedEntity equals: function
]

{ #category : 'tests - from-import' }
FamixPythonProject1Test >> testPackageImportsGlobalVariableFromAModule [

| package global import |
self denyEmpty: self model allImports.
package := self packageNamed: 'subpackageInRoot2'.
global := self globalVariableNamed: 'moduleAtRootVariable'.
import := package outgoingImports detect: [ :pimport | pimport target name = 'moduleAtRootVariable' ].

self assert: import importingEntity equals: package.
self assert: import importedEntity equals: global
]

{ #category : 'tests - from-import' }
FamixPythonProject1Test >> testPackageImportsGlobalVariableFromAPackage [

| package global import |
self denyEmpty: self model allImports.
package := self packageNamed: 'subpackageInRoot2'.
global := self globalVariableNamed: 'rootPackageVariable'.
import := package outgoingImports detect: [ :pimport | pimport target name = 'rootPackageVariable' ].

self assert: import importingEntity equals: package.
self assert: import importedEntity equals: global
]

{ #category : 'tests - packages' }
FamixPythonProject1Test >> testPackageSourceAnchor [

Expand Down

0 comments on commit 20fd303

Please sign in to comment.