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))]
Example #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))]
Example #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))]
Example #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))]
Example #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
Example #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])
Example #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'))]
Example #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))]
Example #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'))]
 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'))]
Example #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), []) == []
Example #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)]
    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)]
    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)) == []
Example #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)]
Example #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)
Example #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)) == []
Example #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)) == []
 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'))]
Example #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'))]
Example #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
Example #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)]
Example #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)]
Example #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]
Example #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 == []
Example #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'))]
Example #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]
Example #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]
Example #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
Example #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
Example #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 == []
Example #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 == []
Example #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
Example #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
Example #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