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

master
Иванов Денис 3 years ago
parent cb199776da
commit b844378505

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

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

@ -1392,6 +1392,15 @@ class TestDirectoryProcessor:
directory_processor.process_template_directories() directory_processor.process_template_directories()
assert os.path.exists(join_paths(CHROOT_PATH, '/etc/copy.gif')) 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): def test_view_tree(self):
list_path = join_paths(CHROOT_PATH, '/etc') list_path = join_paths(CHROOT_PATH, '/etc')
show_tree(list_path) show_tree(list_path)

Loading…
Cancel
Save