File: test_url.py

package info (click to toggle)
xrootd 5.9.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,956 kB
  • sloc: cpp: 244,425; sh: 2,691; python: 1,980; ansic: 1,027; perl: 814; makefile: 272
file content (49 lines) | stat: -rw-r--r-- 1,245 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from XRootD import client
import pytest, sys
from env import *

def test_creation():
  u = client.FileSystem(SERVER_URL).url
  assert u is not None

def test_deletion():
  u = client.FileSystem(SERVER_URL).url
  del u
  pytest.raises(NameError, eval, "u")

def test_valid():
  u = client.FileSystem(SERVER_URL).url
  assert u.is_valid()

def test_invalid():
  u = client.FileSystem('root://').url
  assert u.is_valid() == False

def test_getters():
  u = client.FileSystem("root://user1:passwd1@host1:123//path?param1=val1&param2=val2").url
  assert u.is_valid()
  assert u.hostid == 'user1:passwd1@host1:123'
  assert u.protocol == 'root'
  assert u.username == 'user1'
  assert u.password == 'passwd1'
  assert u.hostname == 'host1'
  assert u.port == 123
  assert u.path == '/path'
  assert u.path_with_params == '/path?param1=val1&param2=val2'

def test_setters():
  u = client.FileSystem(SERVER_URL).url
  u.protocol = 'root'
  assert u.protocol == 'root'
  u.username = 'user1'
  assert u.username == 'user1'
  u.password = 'passwd1'
  assert u.password == 'passwd1'
  u.hostname = 'host1'
  assert u.hostname == 'host1'
  u.port = 123
  assert u.port == 123
  u.path = '/path'
  assert u.path == '/path'
  u.clear()
  assert str(u) == ''