Beispiel #1
0
def test_md5():
    filePath = os.path.join(os.path.dirname(__file__), "sample_md5.txt")
    # result got using command line md5sum, with different line-endings
    # to deal with different GIT configurations:
    expected_lf = "45d1503cb985898ab5bd8e58973007dd"
    expected_crlf = "cf7b48b2fec3b581b135f7c9a1f7ae04"
    assert get_file_md5(filePath) in {expected_lf, expected_crlf}
Beispiel #2
0
def test_md5():
    filePath = os.path.join(os.path.dirname(__file__), "sample_md5.txt")
    # result got using command line md5sum, with different line-endings to deal with different GIT
    # configurations:
    expected_lf = "45d1503cb985898ab5bd8e58973007dd"
    expected_crlf = "cf7b48b2fec3b581b135f7c9a1f7ae04"
    assert get_file_md5(filePath) in {expected_lf, expected_crlf}
Beispiel #3
0
 def test_size_md5(self, dependency1):
     timestamp = os.path.getmtime(dependency1)
     size = os.path.getsize(dependency1)
     md5 = get_file_md5(dependency1)
     dep_stat = os.stat(dependency1)
     # incorrect size dont check md5
     assert check_modified(dependency1, dep_stat, (timestamp+1, size+1, ''))
     # correct size check md5
     assert not check_modified(dependency1, dep_stat, (timestamp+1, size, md5))
     assert check_modified(dependency1, dep_stat, (timestamp+1, size, ''))
Beispiel #4
0
 def _update_dependency_db(self, task):
     for dep in task.file_dep:
         if not os.path.exists(dep):
             continue
         timestamp = os.path.getmtime(dep)
         current = self.dep_manager._get(task.name, dep)
         if current and current[0] == timestamp:
             continue
         size = os.path.getsize(dep)
         self.dep_manager._set(task.name, dep,
                               (timestamp, size, get_file_md5(dep)))
Beispiel #5
0
    def test_file_dep(self, depfile, dependency1):
        my_task = Task("t2", [""], file_dep=['tests/data/dependency1'])
        output = StringIO()
        cmd_reset = CmdFactory(ResetDep, outstream=output, task_list=[my_task],
                               dep_manager=depfile)
        cmd_reset._execute()
        got = output.getvalue()
        assert "processed t2\n" == got

        dep = list(my_task.file_dep)[0]
        timestamp, size, md5 = depfile._get(my_task.name, dep)
        assert get_file_md5(get_abspath("data/dependency1")) == md5
Beispiel #6
0
 def test_size_md5(self, dependency1):
     timestamp = os.path.getmtime(dependency1)
     size = os.path.getsize(dependency1)
     md5 = get_file_md5(dependency1)
     dep_stat = os.stat(dependency1)
     # incorrect size dont check md5
     assert check_modified(dependency1, dep_stat,
                           (timestamp + 1, size + 1, ''))
     # correct size check md5
     assert not check_modified(dependency1, dep_stat,
                               (timestamp + 1, size, md5))
     assert check_modified(dependency1, dep_stat, (timestamp + 1, size, ''))
Beispiel #7
0
    def test_file_dep(self, depfile, dependency1):
        my_task = Task("t2", [""], file_dep=['tests/data/dependency1'])
        output = StringIO()
        cmd_reset = CmdFactory(ResetDep, outstream=output, task_list=[my_task],
                               dep_manager=depfile)
        cmd_reset._execute()
        got = output.getvalue()
        assert "processed t2\n" == got

        dep = list(my_task.file_dep)[0]
        timestamp, size, md5 = depfile._get(my_task.name, dep)
        assert get_file_md5(get_abspath("data/dependency1")) == md5
Beispiel #8
0
def test_md5():
    filePath = os.path.join(os.path.dirname(__file__), "sample_md5.txt")
    # result got using command line md5sum
    expected = "45d1503cb985898ab5bd8e58973007dd"
    assert expected == get_file_md5(filePath)
def test_md5():
    filePath = os.path.join(os.path.dirname(__file__), "sample_md5.txt")
    # result got using command line md5sum
    expected = "45d1503cb985898ab5bd8e58973007dd"
    assert expected == get_file_md5(filePath)