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))]
Esempio n. 2
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))]
Esempio n. 3
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))]
 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))]
Esempio n. 5
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))]
Esempio n. 6
0
 def test_equality(self):
     a = CourseFile('a', 'url', '1990')
     b = CourseFile('b', 'url', '111')
     c = CourseFile('c', 'url', '1111')
     offline_metal = Course('metalli', 'beep.com')
     metal = Course('metalli', 'beep.com')
     offline_metal.append(a, b)
     metal.append(a, b, c)
     assert metal == offline_metal
Esempio n. 7
0
 def test_difference(self):
     a = CourseFile('a', 'url', '1990')
     b = CourseFile('b', 'url', '111')
     c = CourseFile('c', 'url', '1111')
     e = CourseFile('e', 'url', '19')
     offline_metal = Course('metalli', 'beep.com')
     metal = Course('metalli', 'beep.com')
     offline_metal.append(a, b, c)
     metal.append(a, b, e)
     assert set(metal - offline_metal) == set([e])
Esempio n. 8
0
 def test_recursive_olddate(self):
     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')
     sub = Folder('sub', 'fake')
     sub.files.append(a)
     docs.folders.append(sub)
     assert need_syncing(docs, top, []) == [(a, os.path.join(top, 'sub'))]
Esempio n. 9
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))]
Esempio n. 10
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'))]
Esempio n. 11
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'))]
Esempio n. 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('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), []) == []
Esempio n. 13
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)]
Esempio n. 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)]
Esempio n. 15
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)) == []
Esempio n. 16
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)]
Esempio n. 17
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)
Esempio n. 18
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)) == []
Esempio n. 19
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)) == []
Esempio n. 20
0
 def test_recursive_nofileondisk(self, tmpdir):
     gmt1 = GMT1()
     b = tmpdir.mkdir('sub').join('b')
     b.write('content')
     a = CourseFile({'title': 'a.pdf', '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, str(tmpdir)) == [(a, os.path.join(
         str(tmpdir), 'sub'))]
Esempio n. 21
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'))]
Esempio n. 22
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)
 def test_size_calculation(self):
     afile = CourseFile({'title': 'a',
                         'groupId': 5,
                         'uuid': '50-ddf-kek',
                         'size': 1000})
     asecondfile = CourseFile({'title': 'a',
                               'groupId': 5,
                               'uuid': '50-ddf-kek',
                               'size': 10001})
     afile.size = 1099776
     asecondfile.size = 752640
     complete_list = [(afile, '/his/path'), (asecondfile, '/another/path')]
     assert total_size(complete_list) == afile.size + asecondfile.size
Esempio n. 24
0
    def test_flat_datenone(self):
        top = '/a/fake/path'
        a = CourseFile({'title': 'a', 'modifiedDate': 662688060000})
        docs = Folder({'name': 'root', 'friendlyURL': 'fake'})
        docs.files.append(a)

        assert need_syncing(docs, top) == [(a, top)]
Esempio n. 25
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)]
Esempio n. 26
0
    def test_existsonlyonline(self):
        online = Folder({'name': 'online', 'friendlyURL': 'fake'})
        local = Folder({'name': 'local', 'friendlyURL': 'fake'})
        a = CourseFile({'title': 'a', 'modifiedDate': 631152060000})

        online.files.append(a)
        synclocalwithonline(local, online)
        assert local.files == [a]
Esempio n. 27
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 == []
Esempio n. 28
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'))]
Esempio n. 29
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]
Esempio n. 30
0
    def test_recursiveexistsonlyonline(self):
        online = Folder({'name': 'online', 'friendlyURL': 'fake'})
        local = Folder({'name': 'local', 'friendlyURL': 'fake'})
        a = CourseFile({'title': 'a', 'modifiedDate': 631152060000})
        b = CourseFile({'title': 'b', 'modifiedDate': 631152060000})
        c = CourseFile({'title': 'c', 'modifiedDate': 631152060000})
        sub = Folder({'name': 'subfolder'})
        subsub = Folder({'name': 'subsubfolder'})

        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]
Esempio n. 31
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
Esempio n. 32
0
 def test_size_calculation(self):
     afile = CourseFile('name', 'url', '1000')
     asecondfile = CourseFile('name', 'url', '10001')
     afile.size = 1099776
     asecondfile.size = 752640
     complete_list = [(afile, '/his/path'), (asecondfile, '/another/path')]
     assert total_size(complete_list) == afile.size + asecondfile.size
Esempio n. 33
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 == []
Esempio n. 34
0
    def test_recursive_foldernotonline(self):
        online = Folder({'name': 'online', 'friendlyURL': 'fake'})
        local = Folder({'name': 'local', 'friendlyURL': 'fake'})
        a = CourseFile({'title': 'a', 'modifiedDate': 631152060000})
        localsub = Folder({'name': 'sub'})
        localsubsub = Folder({'name': 'subsub'})
        localsubsub.files.append(a)
        onlinesub = Folder({'name': 'sub'})

        localsub.folders.append(localsubsub)
        local.folders.append(localsub)
        online.folders.append(onlinesub)
        synclocalwithonline(local, online)
        assert local.folders[0].folders == []
Esempio n. 35
0
 def test_notequal(self):
     a = CourseFile('nice name', 'beep.com', 'fake time')
     b = CourseFile('another file', 'beep.com', 'fake time')
     assert a != b
Esempio n. 36
0
 def test_folder_size(self):
     COMMON_SIZE = 1099776
     a = CourseFile('name', 'url', '1000')
     b = CourseFile('name', 'url', '10001')
     c = CourseFile('name', 'url', '10001')
     d = CourseFile('name', 'url', '10001')
     e = CourseFile('name', 'url', '10001')
     f = CourseFile('name', 'url', '10001')
     a.size = COMMON_SIZE
     b.size = COMMON_SIZE
     c.size = COMMON_SIZE
     d.size = COMMON_SIZE
     e.size = COMMON_SIZE
     f.size = COMMON_SIZE
     top = Folder('top', 'url')
     middle = Folder('middle', 'url')
     bottom = Folder('bottom', 'url')
     top.files.append(a)
     middle.files.append(b)
     middle.files.append(c)
     bottom.files.append(d)
     bottom.files.append(e)
     bottom.files.append(f)
     middle.folders.append(bottom)
     top.folders.append(middle)
     sizes = []
     assert sum(folder_total_size(top, sizes)) == COMMON_SIZE * 6
Esempio n. 37
0
def step_impl(context):
    fake_course = Course('fakename', 'fakelink')
    file_a = CourseFile('filea', '03/11/14 12.33')
    file_b = CourseFile('fileb', '06/09/14 11.25')
    fake_course.append(file_a, file_b)
    context.selected_course = fake_course
 def test_folder_size(self):
     COMMON_SIZE = 1099776
     a = CourseFile({'title': 'a',
                     'groupId': 5,
                     'uuid': '50-ddf-kek',
                     'size': 1000})
     b = CourseFile({'title': 'a',
                     'groupId': 5,
                     'uuid': '50-ddf-kek',
                     'size': 10001})
     c = CourseFile({'title': 'a',
                     'groupId': 5,
                     'uuid': '50-ddf-kek',
                     'size': 10001})
     d = CourseFile({'title': 'a',
                     'groupId': 5,
                     'uuid': '50-ddf-kek',
                     'size': 10001})
     e = CourseFile({'title': 'a',
                     'groupId': 5,
                     'uuid': '50-ddf-kek',
                     'size': 10001})
     f = CourseFile({'title': 'a',
                     'groupId': 5,
                     'uuid': '50-ddf-kek',
                     'size': 10001})
     a.size = COMMON_SIZE
     b.size = COMMON_SIZE
     c.size = COMMON_SIZE
     d.size = COMMON_SIZE
     e.size = COMMON_SIZE
     f.size = COMMON_SIZE
     top = Folder({'name': 'top', 'friendlyURL': 'url'})
     middle = Folder({'name': 'middle', 'friendlyURL': 'url'})
     bottom = Folder({'name': 'bottom', 'friendlyURL': 'url'})
     top.files.append(a)
     middle.files.append(b)
     middle.files.append(c)
     bottom.files.append(d)
     bottom.files.append(e)
     bottom.files.append(f)
     middle.folders.append(bottom)
     top.folders.append(middle)
     sizes = []
     assert sum(folder_total_size(top, sizes)) == COMMON_SIZE*6