Преглед изворни кода

tests - project0.accdb - add auto refresh linked tables

olivier.massot пре 9 година
родитељ
комит
2486fa55d7

BIN
tests/initial/project0.zip


+ 17 - 0
tests/reference/source/macros/test_export.bas

@@ -0,0 +1,17 @@
+Version =196611
+ColumnsShown =0
+Begin
+    Action ="RunCode"
+    Argument ="test_export()"
+End
+Begin
+    Comment ="_AXL:<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\015\012<UserI"
+        "nterfaceMacro MinimumClientDesignVersion=\"14.0.0000.0000\" xmlns=\"http://schem"
+        "as.microsoft.com/office/accessservices/2009/11/application\" xmlns:a=\"http://sc"
+        "hemas.microsoft.com/office/acc"
+End
+Begin
+    Comment ="_AXL:essservices/2009/11/forms\"><Statements><Action Name=\"RunCode\"><Argument "
+        "Name=\"FunctionName\">test_export()</Argument></Action></Statements></UserInterf"
+        "aceMacro>"
+End

+ 17 - 0
tests/reference/source/macros/test_import.bas

@@ -0,0 +1,17 @@
+Version =196611
+ColumnsShown =0
+Begin
+    Action ="RunCode"
+    Argument ="test_import()"
+End
+Begin
+    Comment ="_AXL:<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"no\"?>\015\012<UserI"
+        "nterfaceMacro MinimumClientDesignVersion=\"14.0.0000.0000\" xmlns=\"http://schem"
+        "as.microsoft.com/office/accessservices/2009/11/application\" xmlns:a=\"http://sc"
+        "hemas.microsoft.com/office/acc"
+End
+Begin
+    Comment ="_AXL:essservices/2009/11/forms\"><Statements><Action Name=\"RunCode\"><Argument "
+        "Name=\"FunctionName\">test_import()</Argument></Action></Statements></UserInterf"
+        "aceMacro>"
+End

+ 90 - 0
tests/reference/source/modules/test_methods.bas

@@ -0,0 +1,90 @@
+Option Compare Database
+Public Const ADDIN_NAME = "OpenAccess.accda"
+
+Sub test()
+    Dim dbpath As String
+    Dim db As DAO.Database
+    Dim td As DAO.TableDef
+    dbpath = CurrentProject.path
+    
+    Set db = CurrentDb
+    Set td = db.TableDefs("linked_table")
+    td.Connect = ";DATABASE=" & dbpath & "\db.accdb"
+    td.RefreshLink
+
+End Sub
+
+
+
+Private Sub setUp_tests()
+    
+    ' update linked table
+    Dim dbpath As String
+    Dim db As DAO.Database
+    Dim td As DAO.TableDef
+    dbpath = CurrentProject.path
+    
+    Set db = CurrentDb
+    Set td = db.TableDefs("linked_table")
+    td.Connect = ";DATABASE=" & dbpath & "\db.accdb"
+    td.RefreshLink
+    
+    ' import reference OpenAccess.accda
+    Dim tmp_path, oa_path As String
+    tmp_path = CurrentProject.path
+    oa_path = tmp_path & "\" & ADDIN_NAME
+    
+    Do Until Dir(oa_path) <> ""
+        If Len(tmp_path) = 0 Then
+            Debug.Print "setUp_tests - Unable to find " & ADDIN_NAME & " in the parents directory"
+            Exit Sub
+        End If
+        
+        tmp_path = parDir(tmp_path)
+        oa_path = tmp_path & "\" & ADDIN_NAME
+
+    Loop
+
+    On Error Resume Next
+    Access.References.AddFromFile (oa_path)
+    
+    DoEvents
+    
+    If Err.Number = 32813 Then
+        'already added
+    Else
+        Debug.Print "setUp_tests - Error while loading " & ADDIN_NAME & " as a reference"
+    End If
+
+End Sub
+
+
+Public Function test_export()
+    'run an OpenAccess export on itself
+    setUp_tests
+    
+    Dim result As Integer
+    result = Application.Run("silent_export")
+
+    Err.Number = result
+    Application.Quit
+
+End Function
+
+Public Function test_import()
+    'run an OpenAccess import on itself
+    setUp_tests
+
+    Dim result As Integer
+    result = Application.Run("silent_import")
+
+    Err.Number = result
+    Application.Quit
+
+End Function
+
+Private Function parDir(ByVal path As String) As String
+    
+    parDir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(path)
+    
+End Function

+ 0 - 1
tests/reference/source/references.csv

@@ -2,5 +2,4 @@
 {4AC9E1DA-5BAD-4AC7-86E3-24F4CDCECA28},12,0
 {2A75196C-D9EB-4129-B803-931327F72D5C},2,8
 {420B2830-E718-11CF-893D-00A0C9054228},1,0
-C:\APPLIS_PARC\OpenAccess\OpenAccess.accda
 {00000600-0000-0010-8000-00AA006D2EA4},6,0

+ 1 - 1
tests/reference/source/tables/USysOpenAccess.txt

@@ -1,3 +1,3 @@
 key	val
 include_tables	USysOpenAccess,TableWithData,TableTestBaseFields,TableTestAdvancedFields
-sources_date	23/11/2016 11:34:34
+sources_date	

+ 14 - 0
tests/run_tests.bat

@@ -56,4 +56,18 @@ copy .\work\project0.accdb .\results\result2.accdb
 echo control existence of backup
 python assert_exists.py .\work\project0.accdb.old
 
+echo ** tests : step 3 **
+
+echo make sources from result1.accdb
+.\results\result1.accdb /X test_export
+move .\results\source .\results\source2
+echo control result
+python compare.py .\results\source2 .\reference\source
+
+echo make sources from result3.accdb
+.\results\result2.accdb /X test_export
+move .\results\source .\results\source3
+echo control result
+python compare.py .\results\source3 .\reference\source  
+
 echo ** end **