Пример #1
0
        public async Task NoFilesOutOfDate()
        {
            var files = BasicFiles;

            using (var libDb = new TemporaryLibAndDB(files))
                using (var analyzer = libDb.Analyzer) {
                    libDb.TouchLibrary(LastWeek, files);
                    libDb.TouchDatabase(Yesterday, files);
                    Assert.IsFalse(await analyzer.Prepare(true));

                    Assert.AreEqual(files.Count(), libDb.FilesInDatabase.Count());
                    Assert.AreEqual(0, analyzer._analyzeFileGroups.Count);
                    Assert.AreEqual(0, analyzer._scrapeFileGroups.Count);
                }
        }
Пример #2
0
        public async Task NoFilesOutOfDate() {
            var files = BasicFiles;
            using (var libDb = new TemporaryLibAndDB(files))
            using (var analyzer = libDb.Analyzer) {
                libDb.TouchLibrary(LastWeek, files);
                libDb.TouchDatabase(Yesterday, files);
                Assert.IsFalse(await analyzer.Prepare(true));

                Assert.AreEqual(files.Count(), libDb.FilesInDatabase.Count());
                Assert.AreEqual(0, analyzer._analyzeFileGroups.Count);
                Assert.AreEqual(0, analyzer._scrapeFileGroups.Count);
            }
        }
Пример #3
0
        public void TemporaryLibTest()
        {
            string libPath = "C:\\", dbPath = "C:\\";

            using (var libDb = new TemporaryLibAndDB(
                       "a.py",
                       "b.pyd",
                       "A1\\__init__.py",
                       "A1\\a.py",
                       "A2\\__init__.py",
                       "A2\\a.py",
                       "site-packages\\B\\__init__.py",
                       "site-packages\\B\\b.py"
                       )) {
                libPath = libDb.Library;
                dbPath  = libDb.Database;

                Assert.AreEqual(8, libDb.FilesInDatabase.Count());
                Assert.AreEqual(8, libDb.FilesInLibrary.Count());

                foreach (var p in libDb.FilesInDatabase)
                {
                    Console.WriteLine(p);
                }

                foreach (var p in libDb.FilesInLibrary)
                {
                    Console.WriteLine(p);
                }

                Assert.IsTrue(File.Exists(Path.Combine(libDb.Database, "database.ver")));
                Assert.AreEqual(
                    PythonTypeDatabase.CurrentVersion,
                    int.Parse(File.ReadAllText(Path.Combine(libDb.Database, "database.ver")))
                    );

                var path = Path.Combine(libDb.Library, "a.py");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Library, "b.pyd");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Library, "A1\\a.py");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Library, "A2\\a.py");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Library, "site-packages\\B\\__init__.py");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Library, "site-packages\\B\\b.py");
                Assert.IsTrue(File.Exists(path), path);

                path = Path.Combine(libDb.Database, "a.idb");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Database, "b.idb");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Database, "A1.a.idb");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Database, "A2.a.idb");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Database, "B", "B.idb");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Database, "B", "B.b.idb");
                Assert.IsTrue(File.Exists(path), path);

                var path1 = Path.Combine(libDb.Library, "a.py");
                var path2 = Path.Combine(libDb.Database, "a.idb");
                libDb.TouchLibrary(LastWeek, "a.py");
                libDb.TouchDatabase("a.py");
                Assert.IsTrue(File.GetLastWriteTime(path1) < File.GetLastWriteTime(path2));
                libDb.TouchDatabase(LastWeek, "a.py");
                libDb.TouchLibrary("a.py");
                Assert.IsTrue(File.GetLastWriteTime(path1) > File.GetLastWriteTime(path2));
            }

            Assert.IsFalse(Directory.Exists(libPath), libPath);
            Assert.IsFalse(Directory.Exists(dbPath), dbPath);
        }
Пример #4
0
        public void TemporaryLibTest() {
            string libPath, dbPath;

            using (var libDb = new TemporaryLibAndDB(
                "a.py",
                "b.pyd",
                "A1\\__init__.py",
                "A1\\a.py",
                "A2\\__init__.py",
                "A2\\a.py",
                "site-packages\\B\\__init__.py",
                "site-packages\\B\\b.py"
            )) {
                libPath = libDb.Library;
                dbPath = libDb.Database;

                Assert.AreEqual(8, libDb.FilesInDatabase.Count());
                Assert.AreEqual(8, libDb.FilesInLibrary.Count());

                foreach (var p in libDb.FilesInDatabase) {
                    Console.WriteLine(p);
                }

                foreach (var p in libDb.FilesInLibrary) {
                    Console.WriteLine(p);
                }

                Assert.IsTrue(File.Exists(Path.Combine(libDb.Database, "database.ver")));
                Assert.AreEqual(
                    PythonTypeDatabase.CurrentVersion,
                    int.Parse(File.ReadAllText(Path.Combine(libDb.Database, "database.ver")))
                );

                var path = Path.Combine(libDb.Library, "a.py");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Library, "b.pyd");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Library, "A1\\a.py");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Library, "A2\\a.py");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Library, "site-packages\\B\\__init__.py");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Library, "site-packages\\B\\b.py");
                Assert.IsTrue(File.Exists(path), path);

                path = Path.Combine(libDb.Database, "a.idb");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Database, "b.idb");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Database, "A1.a.idb");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Database, "A2.a.idb");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Database, "B", "B.idb");
                Assert.IsTrue(File.Exists(path), path);
                path = Path.Combine(libDb.Database, "B", "B.b.idb");
                Assert.IsTrue(File.Exists(path), path);

                var path1 = Path.Combine(libDb.Library, "a.py");
                var path2 = Path.Combine(libDb.Database, "a.idb");
                libDb.TouchLibrary(LastWeek, "a.py");
                libDb.TouchDatabase("a.py");
                Assert.IsTrue(File.GetLastWriteTime(path1) < File.GetLastWriteTime(path2));
                libDb.TouchDatabase(LastWeek, "a.py");
                libDb.TouchLibrary("a.py");
                Assert.IsTrue(File.GetLastWriteTime(path1) > File.GetLastWriteTime(path2));
            }

            Assert.IsFalse(Directory.Exists(libPath), libPath);
            Assert.IsFalse(Directory.Exists(dbPath), dbPath);
        }