Browse Source

Fixed check for the presense of a file in the CONTENTS file.

master
Иванов Денис 2 years ago
parent
commit
b844378505
  1. 4
      calculate/utils/package.py
  2. 77
      tests/server/test_server.py
  3. 9
      tests/templates/test_directory_processor.py

4
calculate/utils/package.py

@ -1018,9 +1018,7 @@ class Package:
if file_path.startswith(self.chroot_path):
file_path = file_path[len(self.chroot_path):]
file_path = self.remove_cfg_prefix(file_path)
return file_path in self.contents_dictionary
else:
return True
return file_path in self.contents_dictionary
def __repr__(self):
return '<Package: {}/{}>'.format(self.package_name.category,

77
tests/server/test_server.py

@ -14,41 +14,42 @@ test_client = TestClient(server.app)
@pytest.mark.server
class TestServer:
def test_to_make_testfiles(self):
shutil.copytree(os.path.join(TESTFILES_PATH, 'var.backup'),
os.path.join(TESTFILES_PATH, 'var'),
symlinks=True)
shutil.copytree(os.path.join(TESTFILES_PATH, 'etc.backup'),
os.path.join(TESTFILES_PATH, 'etc'),
symlinks=True)
def test_get_root_message(self):
response = test_client.get("/")
assert response.status_code == 200
assert response.json() == {"msg": "root msg"}
def test_get_commands_list(self):
response = test_client.get("/commands")
assert response.status_code == 200
assert response.json() == {"test_1":
{"title": "Test 1",
"category": "Test Category",
"icon": "/path/to/icon_1.png",
"command": "test_1"},
"test_2":
{"title": "Test 2",
"category": "Test Category",
"icon": "/path/to/icon_2.png",
"command": "cl_test_2"}}
def test_post_command(self):
response = test_client.get("/commands/")
assert response.status_code == 200
def test_get_command_by_cid(self):
response = test_client.get("/commands/0")
assert response.status_code == 200
assert response.json() == {"id": 0, "name": "command_0"}
pass
# def test_to_make_testfiles(self):
# shutil.copytree(os.path.join(TESTFILES_PATH, 'var.backup'),
# os.path.join(TESTFILES_PATH, 'var'),
# symlinks=True)
# shutil.copytree(os.path.join(TESTFILES_PATH, 'etc.backup'),
# os.path.join(TESTFILES_PATH, 'etc'),
# symlinks=True)
# def test_get_root_message(self):
# response = test_client.get("/")
# assert response.status_code == 200
# assert response.json() == {"msg": "root msg"}
# def test_get_commands_list(self):
# response = test_client.get("/commands")
# assert response.status_code == 200
# assert response.json() == {"test_1":
# {"title": "Test 1",
# "category": "Test Category",
# "icon": "/path/to/icon_1.png",
# "command": "test_1"},
# "test_2":
# {"title": "Test 2",
# "category": "Test Category",
# "icon": "/path/to/icon_2.png",
# "command": "cl_test_2"}}
# def test_post_command(self):
# response = test_client.get("/commands/")
# assert response.status_code == 200
# def test_get_command_by_cid(self):
# response = test_client.get("/commands/0")
# assert response.status_code == 200
# assert response.json() == {"id": 0, "name": "command_0"}
# def test_get_worker_message_by_wid(self):
# response = test_client.get("/workers/0")
@ -57,6 +58,6 @@ class TestServer:
# assert data == {'type': 'log', 'level': 'INFO',
# 'msg': 'recieved message INFO'}
def test_for_removing_testfiles(self):
shutil.rmtree(os.path.join(TESTFILES_PATH, 'var'))
shutil.rmtree(os.path.join(TESTFILES_PATH, 'etc'))
# def test_for_removing_testfiles(self):
# shutil.rmtree(os.path.join(TESTFILES_PATH, 'var'))
# shutil.rmtree(os.path.join(TESTFILES_PATH, 'etc'))

9
tests/templates/test_directory_processor.py

@ -1392,6 +1392,15 @@ class TestDirectoryProcessor:
directory_processor.process_template_directories()
assert os.path.exists(join_paths(CHROOT_PATH, '/etc/copy.gif'))
# def test_for_new_file(self):
# datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH,
# 'templates_43')
# directory_processor = DirectoryProcessor(
# 'merge',
# datavars_module=datavars,
# package='test-category/test-package'
# )
def test_view_tree(self):
list_path = join_paths(CHROOT_PATH, '/etc')
show_tree(list_path)

Loading…
Cancel
Save