Пример #1
0
def test_delete_loops_through_all_resources():
    mox = Mox()
    http_request, model_base, manager, model, queryset = get_mocks(mox)

    fs_mock = mox.CreateMockAnything()
    fs_mock.join('test_web_root', 'some_path').AndReturn("test_web_root/some_path")
    fs_mock.dirname("test_web_root/some_path").AndReturn("test_web_root")
    fs_mock.exists("test_web_root/some_path").AndReturn(True)
    fs_mock.remove("test_web_root/some_path")
    fs_mock.rmdir("test_web_root")

    fs_mock.join('test_web_root', 'some_path_2').AndReturn("test_web_root/some_path_2")
    fs_mock.dirname('test_web_root/some_path_2').AndReturn("test_web_root")
    fs_mock.exists("test_web_root/some_path_2").AndReturn(True)
    fs_mock.remove("test_web_root/some_path_2")
    fs_mock.rmdir("test_web_root")

    settings = CustomSettings(WEB_ROOT="test_web_root")

    mox.ReplayAll()

    instance = StaticGenerator("some_path", "some_path_2", 
                               http_request=http_request,
                               model_base=model_base,
                               manager=manager,
                               model=model,
                               queryset=queryset,
                               settings=settings,
                               fs=fs_mock)

    instance.delete()

    mox.VerifyAll()
def test_delete_loops_through_all_resources():
    mox = Mox()
    http_request, model_base, manager, model, queryset = get_mocks(mox)

    fs_mock = mox.CreateMockAnything()
    fs_mock.join('test_web_root', 'some_path/index.html').AndReturn("test_web_root/some_path")
    fs_mock.dirname("test_web_root/some_path").AndReturn("test_web_root")
    fs_mock.exists("test_web_root/some_path").AndReturn(True)
    fs_mock.remove("test_web_root/some_path")
    fs_mock.rmdir("test_web_root")

    fs_mock.join('test_web_root', 'some_path_2/index.html').AndReturn("test_web_root/some_path_2")
    fs_mock.dirname('test_web_root/some_path_2').AndReturn("test_web_root")
    fs_mock.exists("test_web_root/some_path_2").AndReturn(True)
    fs_mock.remove("test_web_root/some_path_2")
    fs_mock.rmdir("test_web_root")

    settings = CustomSettings(WEB_ROOT="test_web_root")

    mox.ReplayAll()

    instance = StaticGenerator("some_path", "some_path_2", 
                               http_request=http_request,
                               model_base=model_base,
                               manager=manager,
                               model=model,
                               queryset=queryset,
                               settings=settings,
                               fs=fs_mock)

    instance.delete()

    mox.VerifyAll()
    def test_delete_loops_through_all_resources(self):
        instance = StaticGenerator('/some_path', '/some_path_2')
        remove = Mock()
        with nested(patch('os.path.exists', Mock(return_value=True)),
                    patch('os.remove', remove)):

            instance.delete()

        remove.assert_has_calls([call('test_web_root/fresh/some_path'),
                                 call('test_web_root/fresh/some_path_2')])
Пример #4
0
 def test_delete_loops_through_all_resources(self):
     instance = StaticGenerator('/path_one', '/path/two')
     remove = Mock()
     with nested(patch('os.path.exists', Mock(return_value=True)),
                 patch('os.remove', remove)):
         instance.delete()
     # default language cache path contains no language code
     remove.assert_has_calls([call('test_web_root/fresh/path_one'),
                              call('test_web_root/fresh/path_one.gz'),
                              call('test_web_root/fresh/fr.path_one'),
                              call('test_web_root/fresh/fr.path_one.gz'),
                              call('test_web_root/fresh/path/two'),
                              call('test_web_root/fresh/path/two.gz'),
                              call('test_web_root/fresh/path/fr.two'),
                              call('test_web_root/fresh/path/fr.two.gz')])