Beispiel #1
0
 def test_filenotonline(self):
     gmt1 = GMT1()
     online = Folder('online', 'fake')
     local = Folder('local', 'fake')
     a = CourseFile('a', 'url', datetime(1990, 1, 1, 1, 1, tzinfo=gmt1))
     local.files.append(a)
     synclocalwithonline(local, online)
     assert local.files == []
Beispiel #2
0
    def test_flat_datenone(self):
        gmt1 = GMT1()
        top = '/a/fake/path'
        a = CourseFile('a', 'url', datetime(1991, 1, 1, 1, 1, tzinfo=gmt1))
        docs = Folder('root', 'fake')
        docs.files.append(a)

        assert need_syncing(docs, top, []) == [(a, top)]
Beispiel #3
0
 def test_filenamewithoutextension(self, tmpdir):
     gmt1 = GMT1()
     b = tmpdir.join('a.pdf')
     b.write('content')
     a = CourseFile('a', 'url', datetime(1991, 1, 1, 1, 1, tzinfo=gmt1))
     a.local_creation_time = datetime(1990, 1, 1, 1, 1, tzinfo=gmt1)
     docs = Folder('root', 'fake')
     docs.files.append(a)
     assert need_syncing(docs, str(tmpdir), []) == [(a, str(tmpdir))]
Beispiel #4
0
 def test_flat_nofileondisk(self, tmpdir):
     gmt1 = GMT1()
     b = tmpdir.join('b')
     b.write('content')
     a = CourseFile({'title': 'a', 'modifiedDate': 631152060000})
     a.local_creation_time = datetime(1991, 1, 1, 1, 1, tzinfo=gmt1)
     docs = Folder({'name': 'root', 'friendlyURL': 'fake'})
     docs.files.append(a)
     assert need_syncing(docs, str(tmpdir)) == [(a, str(tmpdir))]
Beispiel #5
0
 def test_recursive_datenone(self):
     gmt1 = GMT1()
     top = '/a/fake/path'
     a = CourseFile({'title': 'a', 'modifiedDate': 662688060000})
     docs = Folder({'name': 'root', 'friendlyURL': 'fake'})
     sub = Folder({'name': 'sub', 'friendlyURL': 'fake'})
     sub.files.append(a)
     docs.folders.append(sub)
     assert need_syncing(docs, top) == [(a, os.path.join(top, 'sub'))]
Beispiel #6
0
 def test_recursive_datenone(self):
     gmt1 = GMT1()
     top = '/a/fake/path'
     a = CourseFile('a', 'url', datetime(1991, 1, 1, 1, 1, tzinfo=gmt1))
     docs = Folder('root', 'fake')
     sub = Folder('sub', 'fake')
     sub.files.append(a)
     docs.folders.append(sub)
     assert need_syncing(docs, top, []) == [(a, os.path.join(top, 'sub'))]
Beispiel #7
0
 def test_filenamewithoutextension(self, tmpdir):
     gmt1 = GMT1()
     b = tmpdir.join('a.pdf')
     b.write('content')
     a = CourseFile({'title': 'a', 'modifiedDate': 662688060000})
     a.local_creation_time = datetime(1990, 1, 1, 1, 1, tzinfo=gmt1)
     docs = Folder({'name': 'root', 'friendlyURL': 'fake'})
     docs.files.append(a)
     assert need_syncing(docs, str(tmpdir)) == [(a, str(tmpdir))]
Beispiel #8
0
 def test_flat_nofileondisk2(self, tmpdir):
     """Dates reversed from the previous test"""
     gmt1 = GMT1()
     b = tmpdir.join('b')
     b.write('content')
     a = CourseFile('a.pdf', 'url', datetime(1991, 1, 1, 1, 1, tzinfo=gmt1))
     a.local_creation_time = datetime(1990, 1, 1, 1, 1, tzinfo=gmt1)
     docs = Folder('root', 'fake')
     docs.files.append(a)
     assert need_syncing(docs, str(tmpdir), []) == [(a, str(tmpdir))]
Beispiel #9
0
 def test_recursive_olddate(self):
     gmt1 = GMT1()
     top = '/a/fake/path'
     a = CourseFile({'title': 'a', 'modifiedDate': 662688060000})
     a.local_creation_time = datetime(1990, 1, 1, 1, 1, tzinfo=gmt1)
     docs = Folder({'name': 'root', 'friendlyURL': 'fake'})
     sub = Folder({'name': 'sub', 'friendlyURL': 'fake'})
     sub.files.append(a)
     docs.folders.append(sub)
     assert need_syncing(docs, top) == [(a, os.path.join(top, 'sub'))]
Beispiel #10
0
    def test_flat_olddate(self):
        """local date older: should update the file (doesn't matter if file
        exists or not"""
        gmt1 = GMT1()
        top = '/a/fake/path'
        a = CourseFile('a', 'url', datetime(1991, 1, 1, 1, 1, tzinfo=gmt1))
        a.local_creation_time = datetime(1990, 1, 1, 1, 1, tzinfo=gmt1)
        docs = Folder('root', 'fake')
        docs.files.append(a)

        assert need_syncing(docs, top, []) == [(a, top)]
Beispiel #11
0
 def test_neweronline(self):
     gmt1 = GMT1()
     online = Folder('online', 'fake')
     local = Folder('local', 'fake')
     a = CourseFile('a', 'url', datetime(1991, 1, 1, 1, 1, tzinfo=gmt1))
     b = CourseFile('a', 'url', datetime(1990, 1, 1, 1, 1, tzinfo=gmt1))
     online.files.append(a)
     local.files.append(b)
     synclocalwithonline(local, online)
     assert local.files[0].last_online_edit_time == \
         datetime(1991, 1, 1, 1, 1, tzinfo=gmt1)
Beispiel #12
0
    def test_flat_newdate(self, tmpdir):
        """local date newer: should not update the file if the file exists"""
        gmt1 = GMT1()
        b = tmpdir.join('a')
        b.write('content')
        a = CourseFile({'title': 'a', 'modifiedDate': 631152060000})
        a.local_creation_time = datetime(1991, 1, 1, 1, 1, tzinfo=gmt1)
        docs = Folder({'name': 'root', 'friendlyURL': 'fake'})
        docs.files.append(a)

        assert need_syncing(docs, str(tmpdir)) == []
Beispiel #13
0
    def test_flat_newdate(self, tmpdir):
        """local date newer: should not update the file if the file exists"""
        gmt1 = GMT1()
        b = tmpdir.join('a')
        b.write('content')
        a = CourseFile('a', 'url', datetime(1990, 1, 1, 1, 1, tzinfo=gmt1))
        a.local_creation_time = datetime(1991, 1, 1, 1, 1, tzinfo=gmt1)
        docs = Folder('root', 'fake')
        docs.files.append(a)

        assert need_syncing(docs, str(tmpdir), []) == []
Beispiel #14
0
    def test_flat_olddate(self):
        """local date older: should update the file (doesn't matter if file
        exists or not"""
        gmt1 = GMT1()
        top = '/a/fake/path'
        a = CourseFile({'title': 'a', 'modifiedDate': 662688060000})
        a.local_creation_time = datetime(1990, 1, 1, 1, 1, tzinfo=gmt1)
        docs = Folder({'name': 'root', 'friendlyURL': 'fake'})
        docs.files.append(a)

        assert need_syncing(docs, top) == [(a, top)]
Beispiel #15
0
    def test_recursive_newdate(self, tmpdir):
        gmt1 = GMT1()
        b = tmpdir.mkdir('sub').join('a')
        b.write('content')
        a = CourseFile({'title': 'a', 'modifiedDate': 631152060000})
        a.local_creation_time = datetime(1991, 1, 1, 1, 1, tzinfo=gmt1)
        docs = Folder({'name': 'root', 'friendlyURL': 'fake'})
        sub = Folder({'name': 'sub', 'friendlyURL': 'fake'})
        sub.files.append(a)
        docs.folders.append(sub)

        assert need_syncing(docs, str(tmpdir)) == []
Beispiel #16
0
 def test_foldernotonline(self):
     gmt1 = GMT1()
     online = Folder('online', 'fake')
     local = Folder('local', 'fake')
     a = CourseFile('a', 'url', datetime(1990, 1, 1, 1, 1, tzinfo=gmt1))
     sub = Folder('sub', 'fake')
     sub2 = Folder('sub2', 'fake')
     local.folders.append(sub)
     local.folders.append(sub2)
     online.folders.append(sub)
     synclocalwithonline(local, online)
     assert local.folders == online.folders
Beispiel #17
0
 def test_recursive_nofileondisk(self, tmpdir):
     gmt1 = GMT1()
     b = tmpdir.mkdir('sub').join('b')
     b.write('content')
     a = CourseFile('a.pdf', 'url', datetime(1991, 1, 1, 1, 1, tzinfo=gmt1))
     a.local_creation_time = datetime(1990, 1, 1, 1, 1, tzinfo=gmt1)
     docs = Folder('root', 'fake')
     sub = Folder('sub', 'fake')
     sub.files.append(a)
     docs.folders.append(sub)
     assert need_syncing(docs, str(tmpdir), []) == [(a, os.path.join(
         str(tmpdir), 'sub'))]
Beispiel #18
0
    def test_neweronline(self):
        gmt1 = GMT1()
        online = Folder({'name': 'online', 'friendlyURL': 'fake'})
        local = Folder({'name': 'local', 'friendlyURL': 'fake'})
        a = CourseFile({'title': 'a', 'modifiedDate': 662688060000})
        b = CourseFile({'title': 'b', 'modifiedDate': 631152060000})

        online.files.append(a)
        local.files.append(b)
        synclocalwithonline(local, online)
        assert local.files[0].last_online_edit_time == \
            datetime(1991, 1, 1, 1, 1, tzinfo=gmt1)
Beispiel #19
0
 def test_recursive_foldernotonline(self):
     gmt1 = GMT1()
     online = Folder('online', 'fake')
     local = Folder('local', 'fake')
     a = CourseFile('a', 'url', datetime(1990, 1, 1, 1, 1, tzinfo=gmt1))
     localsub = Folder('sub', 'fake')
     localsubsub = Folder('subsub', 'fake')
     localsubsub.files.append(a)
     onlinesub = Folder('sub', 'fake')
     localsub.folders.append(localsubsub)
     local.folders.append(localsub)
     online.folders.append(onlinesub)
     synclocalwithonline(local, online)
     assert local.folders[0].folders == []
Beispiel #20
0
 def test_recursiveexistsonlyonline(self):
     gmt1 = GMT1()
     online = Folder('online', 'fake')
     local = Folder('local', 'fake')
     a = CourseFile('a', 'url', datetime(1990, 1, 1, 1, 1, tzinfo=gmt1))
     sub = Folder('subfolder', 'fake')
     subsub = Folder('subsubfolder', 'fake')
     b = CourseFile('b', 'url', datetime(1990, 1, 1, 1, 1, tzinfo=gmt1))
     c = CourseFile('c', 'url', datetime(1990, 1, 1, 1, 1, tzinfo=gmt1))
     online.files.append(a)
     sub.files.append(b)
     subsub.files.append(c)
     sub.folders.append(subsub)
     online.folders.append(sub)
     synclocalwithonline(local, online)
     assert local.files == [a]
     assert local.folders == [sub]
     assert local.folders[0].folders == [subsub]
     assert local.folders[0].files == [b]
     assert local.folders[0].folders[0].files == [c]