def test_subpath(self):
     obj = HttpRepoObject(self.dir, 'master.idx')
     assert obj.subpath(1) == ['master.idx']
     assert obj.subpath(2) == ['a', 'master.idx']
예제 #2
0
 def find(self, period_type: DatePeriodType, the_date: Date) -> RepoObject:
     path: List[str] = self.__formatter.format(period_type, the_date)
     dir: HttpRepoDir = self.__root
     for i in path[:-1]:
         dir = HttpRepoDir(make_url(dir.as_uri(), i), dir)
     return HttpRepoObject(dir, path[-1])
 def test_not_exists(self, mock_head):
     obj = HttpRepoObject(self.dir, 'master.idx')
     assert not obj.exists()
 def test_inp_failed(self, mock_get):
     obj = HttpRepoObject(self.dir, 'master.idx')
     it: Iterator = obj.inp()
     assert next(it, None) is None
 def test_inp_two_chunks(self, mock_get):
     obj = HttpRepoObject(self.dir, 'master.idx')
     it: Iterator = obj.inp()
     assert next(it) == 'hello'
     assert next(it) == 'world'
 def test_as_uri(self):
     obj = HttpRepoObject(self.dir, 'master.idx')
     assert self.dir.__setitem__.call_args_list == [call('master.idx', obj)]
     assert obj.as_uri() == 'http://www.site.com/a/master.idx'
예제 #7
0
 def new_object(self, name: str) -> RepoObject:
     return HttpRepoObject(self, name)